### Get Mapped Task Instance Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Demonstrates how to retrieve a mapped task instance using the TaskInstanceApi. It shows setting up the API client with authentication and making the request. Handles potential exceptions during the API call. ```python import airflow_client.client from airflow_client.client.models.task_instance_response import TaskInstanceResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | task_id = 'task_id_example' # str | map_index = 56 # int | try: # Get Mapped Task Instance api_response = api_instance.get_mapped_task_instance(dag_id, dag_run_id, task_id, map_index) print("The response of TaskInstanceApi->get_mapped_task_instance:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->get_mapped_task_instance: %s\n" % e) ``` -------------------------------- ### Python SDK Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/BulkCreateActionBulkTaskInstanceBody.md Example demonstrating how to instantiate and use the BulkCreateActionBulkTaskInstanceBody model in Python using the Airflow client library. ```APIDOC from airflow_client.client.models.bulk_create_action_bulk_task_instance_body import BulkCreateActionBulkTaskInstanceBody # TODO update the JSON string below json_string = "{}" # create an instance of BulkCreateActionBulkTaskInstanceBody from a JSON string bulk_create_action_bulk_task_instance_body_instance = BulkCreateActionBulkTaskInstanceBody.from_json(json_string) # convert the object into a dict bulk_create_action_bulk_task_instance_body_dict = bulk_create_action_bulk_task_instance_body_instance.to_dict() # create an instance of BulkCreateActionBulkTaskInstanceBody from a dict bulk_create_action_bulk_task_instance_body_from_dict = BulkCreateActionBulkTaskInstanceBody.from_dict(bulk_create_action_bulk_task_instance_body_dict) ``` -------------------------------- ### Patch Task Instance Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md This example demonstrates how to patch a task instance using the TaskInstanceApi. It includes setup for authentication and API client configuration. Use this when you need to modify an existing task instance's properties. ```python import airflow_client.client from airflow_client.client.models.patch_task_instance_body import PatchTaskInstanceBody from airflow_client.client.models.task_instance_collection_response import TaskInstanceCollectionResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | task_id = 'task_id_example' # str | patch_task_instance_body = airflow_client.client.PatchTaskInstanceBody() # PatchTaskInstanceBody | map_index = 56 # int | (optional) update_mask = ['update_mask_example'] # List[str] | (optional) try: # Patch Task Instance api_response = api_instance.patch_task_instance(dag_id, dag_run_id, task_id, patch_task_instance_body, map_index=map_index, update_mask=update_mask) print("The response of TaskInstanceApi->patch_task_instance:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->patch_task_instance: %s\n" % e) ``` -------------------------------- ### Get Task Instance Tries Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Demonstrates how to fetch task instance history using the TaskInstanceApi. It includes setup for API client configuration, authentication (OAuth2 or Bearer token), and error handling. Use this when you need to retrieve historical tries for a specific task instance. ```python import airflow_client.client from airflow_client.client.models.task_instance_history_collection_response import TaskInstanceHistoryCollectionResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | task_id = 'task_id_example' # str | map_index = -1 # int | (optional) (default to -1) try: # Get Task Instance Tries api_response = api_instance.get_task_instance_tries(dag_id, dag_run_id, task_id, map_index=map_index) print("The response of TaskInstanceApi->get_task_instance_tries:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->get_task_instance_tries: %s\n" % e) ``` -------------------------------- ### Python SDK Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/BulkUpdateActionPoolBody.md Example demonstrating how to create and manipulate a BulkUpdateActionPoolBody object using the Airflow Python client. ```APIDOC from airflow_client.client.models.bulk_update_action_pool_body import BulkUpdateActionPoolBody # Example usage: # Create an instance from a JSON string (replace with actual JSON data) json_data = "{}" bulk_update_pool_body = BulkUpdateActionPoolBody.from_json(json_data) # Convert the object to a dictionary pool_body_dict = bulk_update_pool_body.to_dict() # Create an instance from a dictionary new_bulk_update_pool_body = BulkUpdateActionPoolBody.from_dict(pool_body_dict) # Print the JSON string representation of the object (Note: to_json() might need an instance) # print(BulkUpdateActionPoolBody.to_json()) # This static call might not be intended for instance conversion ``` -------------------------------- ### Python SDK Usage Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/ResponseGetXcomEntry.md Example demonstrating how to use the ResponseGetXcomEntry model in the Airflow Python client, including instantiation from JSON and conversion to/from dictionaries. ```APIDOC ```python from airflow_client.client.models.response_get_xcom_entry import ResponseGetXcomEntry # TODO update the JSON string below json_string = "{}" # Create an instance of ResponseGetXcomEntry from a JSON string response_get_xcom_entry_instance = ResponseGetXcomEntry.from_json(json_string) # Print the JSON string representation of the object print(ResponseGetXcomEntry.to_json()) # Convert the object into a dict response_get_xcom_entry_dict = response_get_xcom_entry_instance.to_dict() # Create an instance of ResponseGetXcomEntry from a dict response_get_xcom_entry_from_dict = ResponseGetXcomEntry.from_dict(response_get_xcom_entry_dict) ``` ``` -------------------------------- ### Get External Log URL Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Demonstrates how to call the get_external_log_url method to fetch the external log URL for a task instance. Includes setup for API client configuration and authentication. ```python import airflow_client.client from airflow_client.client.models.external_log_url_response import ExternalLogUrlResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | task_id = 'task_id_example' # str | try_number = 56 # int | map_index = -1 # int | (optional) (default to -1) try: # Get External Log Url api_response = api_instance.get_external_log_url(dag_id, dag_run_id, task_id, try_number, map_index=map_index) print("The response of TaskInstanceApi->get_external_log_url:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->get_external_log_url: %s\n" % e) ``` -------------------------------- ### Get Task Instance Try Details with Authentication Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Demonstrates how to retrieve task instance details by try number using the TaskInstanceApi. Includes setup for API client configuration and authentication, with error handling. ```python import airflow_client.client from airflow_client.client.models.task_instance_history_response import TaskInstanceHistoryResponse from airflow_client.client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | task_id = 'task_id_example' # str | task_try_number = 56 # int | map_index = -1 # int | (optional) (default to -1) try: # Get Task Instance Try Details api_response = api_instance.get_task_instance_try_details(dag_id, dag_run_id, task_id, task_try_number, map_index=map_index) print("The response of TaskInstanceApi->get_task_instance_try_details:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->get_task_instance_try_details: %s\n" % e) ``` -------------------------------- ### Configure Airflow Core for Loading Examples Source: https://github.com/apache/airflow-client-python/blob/main/airflow_client/README.md Enable the loading of example DAGs in Airflow. This is necessary for the test script to function correctly. Configure via airflow.cfg or environment variables. ```ini [core] load_examples = True ``` ```bash export AIRFLOW__CORE__LOAD_EXAMPLES=True ``` -------------------------------- ### Install Airflow Client via Pip Source: https://github.com/apache/airflow-client-python/blob/main/airflow_client/README.md Install the latest version of the Airflow client from PyPI. Alternatively, install directly from a Git repository. ```bash pip install apache-airflow-client ``` ```bash pip install git+https://github.com/apache/airflow-client-python.git ``` -------------------------------- ### BackfillResponse Usage Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/BackfillResponse.md Example of how to use the BackfillResponse model, including creating instances from JSON and dictionaries, and converting to JSON and dictionaries. ```python from airflow_client.client.models.backfill_response import BackfillResponse # TODO update the JSON string below json_string = "{}" # create an instance of BackfillResponse from a JSON string backfill_response_instance = BackfillResponse.from_json(json_string) # print the JSON string representation of the object print(BackfillResponse.to_json()) # convert the object into a dict backfill_response_dict = backfill_response_instance.to_dict() # create an instance of BackfillResponse from a dict backfill_response_from_dict = BackfillResponse.from_dict(backfill_response_dict) ``` -------------------------------- ### XComResponseString Usage Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/XComResponseString.md Example demonstrating how to use the XComResponseString model in Python, including instantiation from JSON and conversion to a dictionary. ```APIDOC ## Example ```python from airflow_client.client.models.x_com_response_string import XComResponseString # TODO update the JSON string below json = "{}" # create an instance of XComResponseString from a JSON string x_com_response_string_instance = XComResponseString.from_json(json) # print the JSON string representation of the object print(XComResponseString.to_json()) # convert the object into a dict x_com_response_string_dict = x_com_response_string_instance.to_dict() # create an instance of XComResponseString from a dict x_com_response_string_from_dict = XComResponseString.from_dict(x_com_response_string_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ``` -------------------------------- ### TaskInstancesBatchBody Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstancesBatchBody.md Example of how to create and use a TaskInstancesBatchBody object in Python. ```APIDOC ## Example ```python from airflow_client.client.models.task_instances_batch_body import TaskInstancesBatchBody # TODO update the JSON string below json_string = "{}" # create an instance of TaskInstancesBatchBody from a JSON string task_instances_batch_body_instance = TaskInstancesBatchBody.from_json(json_string) # print the JSON string representation of the object print(TaskInstancesBatchBody.to_json()) # convert the object into a dict task_instances_batch_body_dict = task_instances_batch_body_instance.to_dict() # create an instance of TaskInstancesBatchBody from a dict task_instances_batch_body_from_dict = TaskInstancesBatchBody.from_dict(task_instances_batch_body_dict) ``` ``` -------------------------------- ### Post Clear Task Instances Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md This Python snippet demonstrates how to clear task instances using the TaskInstanceApi. It includes setup for API client configuration, authentication (OAuth2 or Bearer token), and error handling. Ensure you have the necessary access token and have defined the host. ```python import airflow_client.client from airflow_client.client.models.clear_task_instances_body import ClearTaskInstancesBody from airflow_client.client.models.task_instance_collection_response import TaskInstanceCollectionResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | clear_task_instances_body = airflow_client.client.ClearTaskInstancesBody() # ClearTaskInstancesBody | try: # Post Clear Task Instances api_response = api_instance.post_clear_task_instances(dag_id, clear_task_instances_body) print("The response of TaskInstanceApi->post_clear_task_instances:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->post_clear_task_instances: %s\n" % e) ``` -------------------------------- ### XComResponseNative Usage Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/XComResponseNative.md Example demonstrating how to use the XComResponseNative class from the Airflow Python client, including creating instances from JSON and dictionaries, and converting them back. ```APIDOC ## Example ```python from airflow_client.client.models.x_com_response_native import XComResponseNative # TODO update the JSON string below json = "{}" # create an instance of XComResponseNative from a JSON string x_com_response_native_instance = XComResponseNative.from_json(json) # print the JSON string representation of the object print(XComResponseNative.to_json()) # convert the object into a dict x_com_response_native_dict = x_com_response_native_instance.to_dict() # create an instance of XComResponseNative from a dict x_com_response_native_from_dict = XComResponseNative.from_dict(x_com_response_native_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ``` -------------------------------- ### Get Task Instance Dependencies with Python Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Use this snippet to fetch dependencies blocking a task from being scheduled. It demonstrates both OAuth and Bearer token authentication. Ensure you have the airflow-client library installed and your access token configured in environment variables. ```python import airflow_client.client from airflow_client.client.models.task_dependency_collection_response import TaskDependencyCollectionResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | task_id = 'task_id_example' # str | map_index = -1 # int | (optional) (default to -1) try: # Get Task Instance Dependencies api_response = api_instance.get_task_instance_dependencies(dag_id, dag_run_id, task_id, map_index=map_index) print("The response of TaskInstanceApi->get_task_instance_dependencies:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->get_task_instance_dependencies: %s\n" % e) ``` -------------------------------- ### TaskResponse Usage Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskResponse.md Example demonstrating how to create and use a TaskResponse object in Python. ```APIDOC ## Example ```python from airflow_client.client.models.task_response import TaskResponse # TODO update the JSON string below json_string = "{}" # create an instance of TaskResponse from a JSON string task_response_instance = TaskResponse.from_json(json_string) # print the JSON string representation of the object print(TaskResponse.to_json()) # convert the object into a dict task_response_dict = task_response_instance.to_dict() # create an instance of TaskResponse from a dict task_response_from_dict = TaskResponse.from_dict(task_response_dict) ``` ``` -------------------------------- ### JobResponse Usage Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/JobResponse.md Example demonstrating how to use the JobResponse model in Python, including creating instances from JSON and dictionaries, and converting to/from dictionaries. ```APIDOC ## Example ```python from airflow_client.client.models.job_response import JobResponse # TODO update the JSON string below json = "{}" # create an instance of JobResponse from a JSON string job_response_instance = JobResponse.from_json(json) # print the JSON string representation of the object print(JobResponse.to_json()) # convert the object into a dict job_response_dict = job_response_instance.to_dict() # create an instance of JobResponse from a dict job_response_from_dict = JobResponse.from_dict(job_response_dict) ``` ``` -------------------------------- ### Get Task Instance Dependencies Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves the dependencies that are blocking a task from getting scheduled. ```APIDOC ## get_task_instance_dependencies ### Description Get dependencies blocking task from getting scheduled. ### Method GET ### Endpoint /dags/{dag_id}/dagRuns/{dag_run_id}/tasks/{task_id}/dependencies ### Parameters #### Path Parameters - **dag_id** (str) - Required - The identifier of the DAG - **dag_run_id** (str) - Required - The identifier of the DAG run - **task_id** (str) - Required - The identifier of the task #### Query Parameters - **map_index** (int) - Optional - The map index of the task instance. Defaults to -1. ### Response #### Success Response (200) - **TaskDependencyCollectionResponse** - A collection of task dependencies. ### Request Example ```python import airflow_client.client from airflow_client.client.models.task_dependency_collection_response import TaskDependencyCollectionResponse from airflow_client.client.rest import ApiException from pprint import pprint configuration = airflow_client.client.Configuration( host = "http://localhost" ) configuration.access_token = os.environ["ACCESS_TOKEN"] with airflow_client.client.ApiClient(configuration) as api_client: api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' dag_run_id = 'dag_run_id_example' task_id = 'task_id_example' map_index = -1 try: api_response = api_instance.get_task_instance_dependencies(dag_id, dag_run_id, task_id, map_index=map_index) pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->get_task_instance_dependencies: %s\n" % e) ``` ### Authorization - OAuth2PasswordBearer - HTTPBearer ``` -------------------------------- ### Login API Example (Python) Source: https://github.com/apache/airflow-client-python/blob/main/docs/LoginApi.md Demonstrates how to log in using the LoginApi. Requires setting up the API client configuration and handling potential exceptions. ```python import airflow_client.client from airflow_client.client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.LoginApi(api_client) next = 'next_example' # str | (optional) try: # Login api_response = api_instance.login(next=next) print("The response of LoginApi->login:\n") pprint(api_response) except Exception as e: print("Exception when calling LoginApi->login: %s\n" % e) ``` -------------------------------- ### Create and Convert ConfigOption Source: https://github.com/apache/airflow-client-python/blob/main/docs/ConfigOption.md Demonstrates how to create a ConfigOption instance from a JSON string, convert it to a dictionary, and create a new instance from that dictionary. Assumes a placeholder JSON string is used. ```python from airflow_client.client.models.config_option import ConfigOption # TODO update the JSON string below json = "{}" # create an instance of ConfigOption from a JSON string config_option_instance = ConfigOption.from_json(json) # print the JSON string representation of the object print(ConfigOption.to_json()) # convert the object into a dict config_option_dict = config_option_instance.to_dict() # create an instance of ConfigOption from a dict config_option_from_dict = ConfigOption.from_dict(config_option_dict) ``` -------------------------------- ### Instantiate and Convert VersionInfo Source: https://github.com/apache/airflow-client-python/blob/main/docs/VersionInfo.md Demonstrates how to create a VersionInfo instance from a JSON string or a dictionary, and how to convert it back to a dictionary or JSON string. Ensure the JSON string is valid. ```python from airflow_client.client.models.version_info import VersionInfo # TODO update the JSON string below json = "{}" # create an instance of VersionInfo from a JSON string version_info_instance = VersionInfo.from_json(json) # print the JSON string representation of the object print(VersionInfo.to_json()) # convert the object into a dict version_info_dict = version_info_instance.to_dict() # create an instance of VersionInfo from a dict version_info_from_dict = VersionInfo.from_dict(version_info_dict) ``` -------------------------------- ### Get Task Instance Try Details Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves detailed information for a specific try of a task instance. ```APIDOC ## GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/tries/{task_try_number} ### Description Get Task Instance Try Details ### Method GET ### Endpoint /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/tries/{task_try_number} ``` -------------------------------- ### Example Query Parameters for Listing Resources Source: https://github.com/apache/airflow-client-python/blob/main/airflow_client/README.md Use query parameters like 'limit' and 'offset' to paginate through lists of Airflow resources. 'limit' controls the number of items returned, and 'offset' specifies the starting point. ```text v1/connections?limit=25&offset=25 ``` -------------------------------- ### Get Task Instances with OAuth Authentication Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md This snippet demonstrates how to authenticate using OAuth2 and retrieve a list of task instances. It includes various optional parameters for filtering and pagination. ```python import airflow_client.client from airflow_client.client.models.task_instance_collection_response import TaskInstanceCollectionResponse from airflow_client.client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | cursor = 'cursor_example' # str | Cursor for keyset-based pagination. Pass an empty string for the first page, then use ``next_cursor`` from the response. When ``cursor`` is provided, ``offset`` is ignored. (optional) task_id = 'task_id_example' # str | (optional) run_after_gte = '2013-10-20T19:20:30+01:00' # datetime | (optional) run_after_gt = '2013-10-20T19:20:30+01:00' # datetime | (optional) run_after_lte = '2013-10-20T19:20:30+01:00' # datetime | (optional) run_after_lt = '2013-10-20T19:20:30+01:00' # datetime | (optional) logical_date_gte = '2013-10-20T19:20:30+01:00' # datetime | (optional) logical_date_gt = '2013-10-20T19:20:30+01:00' # datetime | (optional) logical_date_lte = '2013-10-20T19:20:30+01:00' # datetime | (optional) logical_date_lt = '2013-10-20T19:20:30+01:00' # datetime | (optional) start_date_gte = '2013-10-20T19:20:30+01:00' # datetime | (optional) start_date_gt = '2013-10-20T19:20:30+01:00' # datetime | (optional) start_date_lte = '2013-10-20T19:20:30+01:00' # datetime | (optional) start_date_lt = '2013-10-20T19:20:30+01:00' # datetime | (optional) end_date_gte = '2013-10-20T19:20:30+01:00' # datetime | (optional) end_date_gt = '2013-10-20T19:20:30+01:00' # datetime | (optional) end_date_lte = '2013-10-20T19:20:30+01:00' # datetime | (optional) ``` -------------------------------- ### Get Task Instance Dependencies by Map Index Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves the dependencies for a mapped task instance. ```APIDOC ## GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/dependencies ### Description Get Task Instance Dependencies ### Method GET ### Endpoint /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/{map_index}/dependencies ``` -------------------------------- ### Get Log Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves the log for a specific try of a task instance. ```APIDOC ## GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/logs/{try_number} ### Description Get Log ### Method GET ### Endpoint /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/logs/{try_number} ``` -------------------------------- ### FastAPIRootMiddlewareResponse Usage Example Source: https://github.com/apache/airflow-client-python/blob/main/docs/FastAPIRootMiddlewareResponse.md Demonstrates how to create an instance of FastAPIRootMiddlewareResponse from a JSON string, convert it to a dictionary, and create it from a dictionary. Ensure the JSON string is valid. ```python from airflow_client.client.models.fast_api_root_middleware_response import FastAPIRootMiddlewareResponse # TODO update the JSON string below json = "{}" # create an instance of FastAPIRootMiddlewareResponse from a JSON string fast_api_root_middleware_response_instance = FastAPIRootMiddlewareResponse.from_json(json) # print the JSON string representation of the object print(FastAPIRootMiddlewareResponse.to_json()) # convert the object into a dict fast_api_root_middleware_response_dict = fast_api_root_middleware_response_instance.to_dict() # create an instance of FastAPIRootMiddlewareResponse from a dict fast_api_root_middleware_response_from_dict = FastAPIRootMiddlewareResponse.from_dict(fast_api_root_middleware_response_dict) ``` -------------------------------- ### Get Task Instance with Airflow Client Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Demonstrates how to retrieve a task instance using the TaskInstanceApi. Requires configuration of the API host and authentication. Handles potential exceptions during the API call. ```python import airflow_client.client from airflow_client.client.models.task_instance_response import TaskInstanceResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.TaskInstanceApi(api_client) dag_id = 'dag_id_example' # str | dag_run_id = 'dag_run_id_example' # str | task_id = 'task_id_example' # str | try: # Get Task Instance api_response = api_instance.get_task_instance(dag_id, dag_run_id, task_id) print("The response of TaskInstanceApi->get_task_instance:\n") pprint(api_response) except Exception as e: print("Exception when calling TaskInstanceApi->get_task_instance: %s\n" % e) ``` -------------------------------- ### Get Task Instances Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves a list of task instances for a DAG run. ```APIDOC ## GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances ### Description Get Task Instances ### Method GET ### Endpoint /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances ``` -------------------------------- ### Get HITL Details with Authentication Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Demonstrates how to configure the Airflow client for authentication using either OAuth2 or Bearer tokens. Ensure your access token is set in the environment variables. ```python import airflow_client.client from airflow_client.client.models.hitl_detail_collection import HITLDetailCollection from airflow_client.client.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) ``` -------------------------------- ### Get Task Instance Tries Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves all tries for a task instance. ```APIDOC ## GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/tries ### Description Get Task Instance Tries ### Method GET ### Endpoint /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/tries ``` -------------------------------- ### Get Hitl Details Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves all Hitl details for a DAG run. ```APIDOC ## GET /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/hitlDetails ### Description Get Hitl Details ### Method GET ### Endpoint /api/v2/dags/{dag_id}/dagRuns/{dag_run_id}/hitlDetails ``` -------------------------------- ### Get Task Instances Source: https://github.com/apache/airflow-client-python/blob/main/docs/TaskInstanceApi.md Retrieves a list of task instances, with extensive filtering options available. This method supports keyset-based pagination using a cursor. ```APIDOC ## GET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances ### Description Retrieves a list of task instances for a specific DAG run, with support for various filtering criteria and keyset-based pagination. ### Method GET ### Endpoint /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances ### Parameters #### Path Parameters - **dag_id** (str) - Required - The DAG ID. - **dag_run_id** (str) - Required - The DAG run ID. #### Query Parameters - **cursor** (str) - Optional - Cursor for keyset-based pagination. Pass an empty string for the first page, then use `next_cursor` from the response. When `cursor` is provided, `offset` is ignored. - **task_id** (str) - Optional - Filter by task ID. - **run_after_gte** (datetime) - Optional - Filter by run after (greater than or equal to). - **run_after_gt** (datetime) - Optional - Filter by run after (greater than). - **run_after_lte** (datetime) - Optional - Filter by run after (less than or equal to). - **run_after_lt** (datetime) - Optional - Filter by run after (less than). - **logical_date_gte** (datetime) - Optional - Filter by logical date (greater than or equal to). - **logical_date_gt** (datetime) - Optional - Filter by logical date (greater than). - **logical_date_lte** (datetime) - Optional - Filter by logical date (less than or equal to). - **logical_date_lt** (datetime) - Optional - Filter by logical date (less than). - **start_date_gte** (datetime) - Optional - Filter by start date (greater than or equal to). - **start_date_gt** (datetime) - Optional - Filter by start date (greater than). - **start_date_lte** (datetime) - Optional - Filter by start date (less than or equal to). - **start_date_lt** (datetime) - Optional - Filter by start date (less than). - **end_date_gte** (datetime) - Optional - Filter by end date (greater than or equal to). - **end_date_gt** (datetime) - Optional - Filter by end date (greater than). - **end_date_lte** (datetime) - Optional - Filter by end date (less than or equal to). - **end_date_lt** (datetime) - Optional - Filter by end date (less than). - **updated_at_gte** (datetime) - Optional - Filter by updated at (greater than or equal to). - **updated_at_gt** (datetime) - Optional - Filter by updated at (greater than). - **updated_at_lte** (datetime) - Optional - Filter by updated at (less than or equal to). - **updated_at_lt** (datetime) - Optional - Filter by updated at (less than). - **duration_gte** (float) - Optional - Filter by duration (greater than or equal to). - **duration_gt** (float) - Optional - Filter by duration (greater than). - **duration_lte** (float) - Optional - Filter by duration (less than or equal to). - **duration_lt** (float) - Optional - Filter by duration (less than). - **task_display_name_pattern** (str) - Optional - SQL LIKE expression for task display name (e.g. `%customer_%`). Supports `|` for OR logic. Does not support regular expressions. Performance note: this pattern is evaluated as `ILIKE '%term%'` and can be slow on large tables. Prefer `task_display_name_prefix_pattern` when possible. - **task_display_name_prefix_pattern** (str) - Optional - Prefix match on task display name. Case-sensitive. Index-friendly alternative to `task_display_name_pattern`. Use `|` for OR. Use `~` to match all. Trailing non-alphanumeric characters are stripped before matching. - **task_group_id** (str) - Optional - Filter by task group ID. - **dag_id_pattern** (str) - Optional - SQL LIKE expression for DAG ID. - **dag_id_prefix_pattern** (str) - Optional - Prefix match on DAG ID. - **run_id_pattern** (str) - Optional - SQL LIKE expression for run ID. - **run_id_prefix_pattern** (str) - Optional - Prefix match on run ID. - **state** (str) - Optional - Filter by task state. - **pool** (str) - Optional - Filter by pool. - **pool_name_pattern** (str) - Optional - SQL LIKE expression for pool name. - **pool_name_prefix_pattern** (str) - Optional - Prefix match on pool name. - **queue** (str) - Optional - Filter by queue. - **queue_name_pattern** (str) - Optional - SQL LIKE expression for queue name. - **queue_name_prefix_pattern** (str) - Optional - Prefix match on queue name. - **executor** (str) - Optional - Filter by executor. - **version_number** (int) - Optional - Filter by version number. - **try_number** (int) - Optional - Filter by try number. - **operator** (str) - Optional - Filter by operator. - **operator_name_pattern** (str) - Optional - SQL LIKE expression for operator name. - **operator_name_prefix_pattern** (str) - Optional - Prefix match on operator name. - **map_index** (int) - Optional - Filter by map index. - **rendered_map_index_pattern** (str) - Optional - SQL LIKE expression for rendered map index. - **rendered_map_index_prefix_pattern** (str) - Optional - Prefix match on rendered map index. - **limit** (int) - Optional - The number of results to return. - **offset** (int) - Optional - The number of results to skip. Ignored if `cursor` is provided. - **order_by** (str) - Optional - The order in which to sort the results. Example: `task_id` or `-task_id` for descending. ### Request Example ```python # Assuming api_instance is an initialized TaskInstanceApi object # and dag_id, dag_run_id are defined api_response = api_instance.get_task_instances( dag_id=dag_id, dag_run_id=dag_run_id, task_id="my_task", state="success", limit=10 ) print(api_response) ``` ### Response #### Success Response (200) - **task_instances** (list) - A list of task instance objects. - **next_cursor** (str) - The cursor for the next page of results, if available. #### Response Example ```json { "task_instances": [ { "dag_id": "my_dag", "dag_run_id": "manual__2023-01-01T00:00:00+00:00", "task_id": "task_1", "run_id": "manual__2023-01-01T00:00:00+00:00", "execution_date": "2023-01-01T00:00:00+00:00", "start_date": "2023-01-01T00:01:00+00:00", "end_date": "2023-01-01T00:02:00+00:00", "duration": 60.0, "state": "success", "try_number": 1, "operator": "BashOperator", "queue": "default" } ], "next_cursor": "some_opaque_cursor_string" } ``` ``` -------------------------------- ### Create and Convert ResponseGetXcomEntry Source: https://github.com/apache/airflow-client-python/blob/main/docs/ResponseGetXcomEntry.md Demonstrates how to create an instance of ResponseGetXcomEntry from a JSON string, convert it to a dictionary, and create a new instance from that dictionary. Requires the ResponseGetXcomEntry model to be imported. ```python from airflow_client.client.models.response_get_xcom_entry import ResponseGetXcomEntry # TODO update the JSON string below json = "{}" # create an instance of ResponseGetXcomEntry from a JSON string response_get_xcom_entry_instance = ResponseGetXcomEntry.from_json(json) # print the JSON string representation of the object print(ResponseGetXcomEntry.to_json()) # convert the object into a dict response_get_xcom_entry_dict = response_get_xcom_entry_instance.to_dict() # create an instance of ResponseGetXcomEntry from a dict response_get_xcom_entry_from_dict = ResponseGetXcomEntry.from_dict(response_get_xcom_entry_dict) ``` -------------------------------- ### Get Airflow Connection by ID Source: https://github.com/apache/airflow-client-python/blob/main/docs/ConnectionApi.md Retrieves a specific connection entry from Airflow using its ID. Ensure you have configured authentication (e.g., Bearer Token) and set the host correctly. This example demonstrates using Bearer Authentication. ```python import airflow_client.client from airflow_client.client.models.connection_response import ConnectionResponse from airflow_client.client.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = airflow_client.client.Configuration( host = "http://localhost" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. configuration.access_token = os.environ["ACCESS_TOKEN"] # Configure Bearer authorization: HTTPBearer configuration = airflow_client.client.Configuration( access_token = os.environ["BEARER_TOKEN"] ) # Enter a context with an instance of the API client with airflow_client.client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = airflow_client.client.ConnectionApi(api_client) connection_id = 'connection_id_example' # str | try: # Get Connection api_response = api_instance.get_connection(connection_id) print("The response of ConnectionApi->get_connection:\n") pprint(api_response) except Exception as e: print("Exception when calling ConnectionApi->get_connection: %s\n" % e) ```