From 53dda94769c50c4a8adf3a0c084a06d078c58a98 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 17 Jan 2024 17:19:04 -0500 Subject: [PATCH] Add list method to Operation class --- neon_client/client.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/neon_client/client.py b/neon_client/client.py index 8724cfe..f55680e 100644 --- a/neon_client/client.py +++ b/neon_client/client.py @@ -202,7 +202,28 @@ class Branch(NeonResource): class Operation(NeonResource): - pass + @classmethod + def list( + cls, + client, + project_id: str, + *, + cursor: int | None = None, + limit: int | None = None, + ): + """Get a list of operations.""" + + r_path = client.url_join("projects", project_id, "operations") + r_params = compact_mapping({"cursor": cursor, "limit": limit}) + + # Make the request. + r = client.request("GET", r_path, params=r_params) + r = schema.OperationsResponse(**r).model_dump() + + return [ + cls(client=client, obj=o, data_model=schema.Operation) + for o in r["operations"] + ] class NeonAPI: