bugraoz93 commented on code in PR #50132:
URL: https://github.com/apache/airflow/pull/50132#discussion_r2175408726
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -148,6 +150,33 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr,
_check_flag_and_exit_if_server_response_error(value))
+ def return_all_entries(
+ self,
+ *,
+ path: str,
+ total_entries: int,
+ data_model: type[BaseModel],
+ entry_list: list,
+ offset: int = 0,
+ limit: int = 50,
+ params: dict | None = None,
+ **kwargs,
+ ) -> list | ServerResponseError:
+ if params is None:
+ params = {}
+ params.update({"limit": limit}, **kwargs)
+ try:
+ while offset < total_entries:
+ params.update({"offset": offset})
+ self.response = self.client.get(path, params=params)
+ entry = data_model.model_validate_json(self.response.content)
+ offset = offset + limit # default limit params = 50
+ entry_list.append(entry)
+
+ return entry_list
+ except ServerResponseError as e:
+ raise e
Review Comment:
I think we should move it to a generic method and not add them into
individual methods and abstracting entire calls into that method should easily
eliminate duplicate calls of the same error. Both works for now, you can also
do it elsewhere. We need to refactor a bit how we throw the exceptions in the
future, where there are lots of duplicate calls that can be generalised
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]