Lee-W commented on code in PR #45634: URL: https://github.com/apache/airflow/pull/45634#discussion_r1926250127
########## providers/src/airflow/providers/dbt/cloud/hooks/dbt.py: ########## @@ -376,27 +385,73 @@ def get_project(self, project_id: int, account_id: int | None = None) -> Respons """ return self._run_and_get_response(endpoint=f"{account_id}/projects/{project_id}/", api_version="v3") + @fallback_to_default_account + def list_environments( + self, project_id: int, name_contains: str | None = None, account_id: int | None = None + ) -> list[Response]: + """ + Retrieve metadata for all environments tied to a specified dbt Cloud project. + + :param project_id: The ID of a dbt Cloud project. + :param name_contains: Optional. The case-insensitive substring of a dbt Cloud environment name to filter by. + :param account_id: Optional. The ID of a dbt Cloud account. + :return: List of request responses. + """ + payload = {"name__icontains": name_contains} if name_contains else None + return self._run_and_get_response( + endpoint=f"{account_id}/projects/{project_id}/environments/", + payload=payload, + paginate=True, + api_version="v3", + ) + + @fallback_to_default_account + def get_environment( + self, project_id: int, environment_id: int, account_id: int | None = None + ) -> Response: + """ + Retrieve metadata for a specific project's environment. + + :param project_id: The ID of a dbt Cloud project. + :param environment_id: The ID of a dbt Cloud environment. + :param account_id: Optional. The ID of a dbt Cloud account. + :return: The request response. + """ + return self._run_and_get_response( + endpoint=f"{account_id}/projects/{project_id}/environments/{environment_id}/", api_version="v3" + ) + @fallback_to_default_account def list_jobs( self, account_id: int | None = None, order_by: str | None = None, project_id: int | None = None, + environment_id: int | None = None, + name_contains: str | None = None, ) -> list[Response]: """ Retrieve metadata for all jobs tied to a specified dbt Cloud account. If a ``project_id`` is supplied, only jobs pertaining to this project will be retrieved. + If an ``environment_id`` is supplied, only jobs pertaining to this environment will be retrieved. :param account_id: Optional. The ID of a dbt Cloud account. :param order_by: Optional. Field to order the result by. Use '-' to indicate reverse order. For example, to use reverse order by the run ID use ``order_by=-id``. - :param project_id: The ID of a dbt Cloud project. + :param project_id: Optional. The ID of a dbt Cloud project. + :param environment_id: Optional. The ID of a dbt Cloud environment. + :param name_contains: Optional. The case-insensitive substring of a dbt Cloud job name to filter by. Review Comment: yep, same here. no strong opinion on this one. Probably makes more sense for one more familiar with dbt API to decide. just would like to confirm 🙂 -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org