pierrejeambrun commented on code in PR #50132:
URL: https://github.com/apache/airflow/pull/50132#discussion_r2221853049
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -147,6 +150,42 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr,
_check_flag_and_exit_if_server_response_error(value))
+ def execute_list(
+ self,
+ *,
+ path: str,
+ data_model: type[T],
+ offset: int = 0,
+ limit: int = 50,
+ params: dict | None = None,
+ **kwargs,
+ ) -> T | ServerResponseError:
+ shared_params = {**(params or {}), **kwargs}
+ try:
+ self.response = self.client.get(path, params=shared_params)
+ first_pass = data_model.model_validate_json(self.response.content)
+ total_entries = first_pass.total_entries # type:
ignore[attr-defined]
+ if total_entries < limit:
+ return first_pass
+ for key, value in first_pass.model_dump().items():
+ if key != "total_entries" and isinstance(value, list):
+ break
+ entry_list = getattr(first_pass, key)
+ total_entries = first_pass.total_entries # type:
ignore[attr-defined]
Review Comment:
And there
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -147,6 +150,42 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr,
_check_flag_and_exit_if_server_response_error(value))
+ def execute_list(
+ self,
+ *,
+ path: str,
+ data_model: type[T],
+ offset: int = 0,
+ limit: int = 50,
+ params: dict | None = None,
+ **kwargs,
+ ) -> T | ServerResponseError:
+ shared_params = {**(params or {}), **kwargs}
Review Comment:
Why are `params` shoved into `shared_params` we already have `params` for
that, we should either remove `params` and default `kwargs` to the extra params
or remove `kwrags` as an extra param.
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -147,6 +150,42 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr,
_check_flag_and_exit_if_server_response_error(value))
+ def execute_list(
+ self,
+ *,
+ path: str,
+ data_model: type[T],
+ offset: int = 0,
+ limit: int = 50,
+ params: dict | None = None,
+ **kwargs,
+ ) -> T | ServerResponseError:
+ shared_params = {**(params or {}), **kwargs}
+ try:
+ self.response = self.client.get(path, params=shared_params)
+ first_pass = data_model.model_validate_json(self.response.content)
+ total_entries = first_pass.total_entries # type:
ignore[attr-defined]
Review Comment:
This is done two times, we don't need that.
total_entries = first_pass.total_entries # type: ignore[attr-defined]
--
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]