Apache Airflow Python Client.XComApi

All URIs are relative to http://localhost/api/v1

MethodHTTP requestDescription
get_xcom_entriesGET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntriesList XCom entries
get_xcom_entryGET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries/{xcom_key}Get an XCom entry

get_xcom_entries

object get_xcom_entries(dag_id, dag_run_id, task_id)

List XCom entries

This endpoint allows specifying ~ as the dag_id, dag_run_id, task_id to retrieve XCOM entries for for all DAGs, DAG runs and task instances. XCom values won't be returned as they can be large. Use this endpoint to get a list of XCom entries and then fetch individual entry to get value.

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import x_com_api
from airflow_client.client.model.error import Error
from pprint import pprint
# Defining the host is optional and defaults to http://localhost/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = client.Configuration(
    host = "http://localhost/api/v1"
)

# 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.

# Configure HTTP basic authorization: Basic
configuration = client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = x_com_api.XComApi(api_client)
    dag_id = "dag_id_example" # str | The DAG ID.
    dag_run_id = "dag_run_id_example" # str | The DAG run ID.
    task_id = "task_id_example" # str | The task ID.
    limit = 100 # int | The numbers of items to return. (optional) if omitted the server will use the default value of 100
    offset = 0 # int | The number of items to skip before starting to collect the result set. (optional)

    # example passing only required values which don't have defaults set
    try:
        # List XCom entries
        api_response = api_instance.get_xcom_entries(dag_id, dag_run_id, task_id)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling XComApi->get_xcom_entries: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # List XCom entries
        api_response = api_instance.get_xcom_entries(dag_id, dag_run_id, task_id, limit=limit, offset=offset)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling XComApi->get_xcom_entries: %s\n" % e)

Parameters

NameTypeDescriptionNotes
dag_idstrThe DAG ID.
dag_run_idstrThe DAG run ID.
task_idstrThe task ID.
limitintThe numbers of items to return.[optional] if omitted the server will use the default value of 100
offsetintThe number of items to skip before starting to collect the result set.[optional]

Return type

object

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Success.-
401Request not authenticated due to missing, invalid, authentication info.-
403Client does not have sufficient permission.-

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_xcom_entry

XCom get_xcom_entry(dag_id, dag_run_id, task_id, xcom_key)

Get an XCom entry

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import x_com_api
from airflow_client.client.model.x_com import XCom
from airflow_client.client.model.error import Error
from pprint import pprint
# Defining the host is optional and defaults to http://localhost/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = client.Configuration(
    host = "http://localhost/api/v1"
)

# 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.

# Configure HTTP basic authorization: Basic
configuration = client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = x_com_api.XComApi(api_client)
    dag_id = "dag_id_example" # str | The DAG ID.
    dag_run_id = "dag_run_id_example" # str | The DAG run ID.
    task_id = "task_id_example" # str | The task ID.
    xcom_key = "xcom_key_example" # str | The XCom key.

    # example passing only required values which don't have defaults set
    try:
        # Get an XCom entry
        api_response = api_instance.get_xcom_entry(dag_id, dag_run_id, task_id, xcom_key)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling XComApi->get_xcom_entry: %s\n" % e)

Parameters

NameTypeDescriptionNotes
dag_idstrThe DAG ID.
dag_run_idstrThe DAG run ID.
task_idstrThe task ID.
xcom_keystrThe XCom key.

Return type

XCom

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Success.-
401Request not authenticated due to missing, invalid, authentication info.-
403Client does not have sufficient permission.-
404A specified resource is not found.-

[Back to top] [Back to API list] [Back to Model list] [Back to README]