bugraoz93 commented on code in PR #50132:
URL: https://github.com/apache/airflow/pull/50132#discussion_r2159430679
##########
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:
We need to handle the exceptions closer to the cli layer to prevent custom
logging on the API end. So we are generally throwing here, and whoever calls in
ctl/cli catch it with proper errors. Do you think we should handle them here?
--
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]