bugraoz93 commented on code in PR #63017: URL: https://github.com/apache/airflow/pull/63017#discussion_r2898193339
########## airflow-ctl/docs/howto/index.rst: ########## @@ -114,6 +114,35 @@ This parameter is useful when you want to manage multiple Airflow environments. Useful when there's no keyring available in the system where airflowctl is running. Set ``AIRFLOW_CLI_TOKEN`` or use the ``--api-token`` flag for next commands. + +Use Airflow Ctl (airflowctl) as SDK +''''''''''''''''''''''''''''''''''' +airflowctl can also be used as a Python SDK to interact with the Airflow API programmatically. +You can import the necessary modules and use the functions provided by airflowctl to perform various operations on the Airflow API. + + +.. code-block:: python + + import httpx + from airflow_ctl.api.client import Client, Credentials, ServerResponseError + from airflowctl.api.datamodels.generated import DAGPatchBody + + # Reusable API Client until token expires + api_client = Client( + base_url="AIRFLOW_API_URL", + limits=httpx.Limits(max_keepalive_connections=1, max_connections=1), + token="TOKEN", + ) + + # Example: Pausing a DAG + dag_id = "EXAMPLE_DAG_ID" + try: + api_client.dags.update(dag_id=dag_id, dag_body=DAGPatchBody(is_paused="pause")) + except ServerResponseError as e: + # Handle error + pass Review Comment: This is exact comment I needed Kaxil, thanks :D I wasn't fully sure until we have full parity and auto generation for all endpoints without having LoC. I thought it could be maybe useful for some small cases so maybe we can have early feedback to construct naturally rather big bang. Still agree on additional effort. I am not persistent to open it while wanted to collect feedback on this :) Maybe after 1.0 and things started evolving more stable 🤔 Please let me know your thoughts, really valuable :) -- 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]
