Apache Airflow Python Client.TaskInstanceApi

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

MethodHTTP requestDescription
get_extra_linksGET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/linksList extra links
get_logGET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/logs/{task_try_number}Get logs
get_task_instanceGET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}Get a task instance
get_task_instancesGET /dags/{dag_id}/dagRuns/{dag_run_id}/taskInstancesList task instances
get_task_instances_batchPOST /dags//dagRuns//taskInstances/listList task instances (batch)

get_extra_links

ExtraLinkCollection get_extra_links(dag_id, dag_run_id, task_id)

List extra links

List extra links for task instance.

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import task_instance_api
from airflow_client.client.model.extra_link_collection import ExtraLinkCollection
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 = task_instance_api.TaskInstanceApi(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.

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

Parameters

NameTypeDescriptionNotes
dag_idstrThe DAG ID.
dag_run_idstrThe DAG run ID.
task_idstrThe task ID.

Return type

ExtraLinkCollection

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]

get_log

InlineResponse200 get_log(dag_id, dag_run_id, task_id, task_try_number)

Get logs

Get logs for a specific task instance and its try number.

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import task_instance_api
from airflow_client.client.model.error import Error
from airflow_client.client.model.inline_response200 import InlineResponse200
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 = task_instance_api.TaskInstanceApi(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.
    task_try_number = 1 # int | The task try number.
    full_content = True # bool | A full content will be returned. By default, only the first fragment will be returned.  (optional)
    token = "token_example" # str | A token that allows you to continue fetching logs. If passed, it will specify the location from which the download should be continued.  (optional)

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

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Get logs
        api_response = api_instance.get_log(dag_id, dag_run_id, task_id, task_try_number, full_content=full_content, token=token)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling TaskInstanceApi->get_log: %s\n" % e)

Parameters

NameTypeDescriptionNotes
dag_idstrThe DAG ID.
dag_run_idstrThe DAG run ID.
task_idstrThe task ID.
task_try_numberintThe task try number.
full_contentboolA full content will be returned. By default, only the first fragment will be returned.[optional]
tokenstrA token that allows you to continue fetching logs. If passed, it will specify the location from which the download should be continued.[optional]

Return type

InlineResponse200

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json, text/plain

HTTP response details

Status codeDescriptionResponse headers
200Success.-
400Client specified an invalid argument.-
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]

get_task_instance

TaskInstance get_task_instance(dag_id, dag_run_id, task_id)

Get a task instance

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import task_instance_api
from airflow_client.client.model.task_instance import TaskInstance
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 = task_instance_api.TaskInstanceApi(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.

    # example passing only required values which don't have defaults set
    try:
        # Get a task instance
        api_response = api_instance.get_task_instance(dag_id, dag_run_id, task_id)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling TaskInstanceApi->get_task_instance: %s\n" % e)

Parameters

NameTypeDescriptionNotes
dag_idstrThe DAG ID.
dag_run_idstrThe DAG run ID.
task_idstrThe task ID.

Return type

TaskInstance

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]

get_task_instances

TaskInstanceCollection get_task_instances(dag_id, dag_run_id)

List task instances

This endpoint allows specifying ~ as the dag_id, dag_run_id to retrieve DAG runs for all DAGs and DAG runs.

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import task_instance_api
from airflow_client.client.model.task_instance_collection import TaskInstanceCollection
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 = task_instance_api.TaskInstanceApi(api_client)
    dag_id = "dag_id_example" # str | The DAG ID.
    dag_run_id = "dag_run_id_example" # str | The DAG run ID.
    execution_date_gte = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Returns objects greater or equal to the specified date.  This can be combined with execution_date_lte parameter to receive only the selected period.  (optional)
    execution_date_lte = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Returns objects less than or equal to the specified date.  This can be combined with execution_date_gte parameter to receive only the selected period.  (optional)
    start_date_gte = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Returns objects greater or equal the specified date.  This can be combined with start_date_lte parameter to receive only the selected period.  (optional)
    start_date_lte = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Returns objects less or equal the specified date.  This can be combined with start_date_gte parameter to receive only the selected period.  (optional)
    end_date_gte = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Returns objects greater or equal the specified date.  This can be combined with start_date_lte parameter to receive only the selected period.  (optional)
    end_date_lte = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | Returns objects less than or equal to the specified date.  This can be combined with start_date_gte parameter to receive only the selected period.  (optional)
    duration_gte = 3.14 # float | Returns objects greater than or equal to the specified values.  This can be combined with duration_lte parameter to receive only the selected period.  (optional)
    duration_lte = 3.14 # float | Returns objects less than or equal to the specified values.  This can be combined with duration_gte parameter to receive only the selected range.  (optional)
    state = [
        "state_example",
    ] # [str] | The value can be repeated to retrieve multiple matching values (OR condition). (optional)
    pool = [
        "pool_example",
    ] # [str] | The value can be repeated to retrieve multiple matching values (OR condition). (optional)
    queue = [
        "queue_example",
    ] # [str] | The value can be repeated to retrieve multiple matching values (OR condition). (optional)
    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 task instances
        api_response = api_instance.get_task_instances(dag_id, dag_run_id)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling TaskInstanceApi->get_task_instances: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # List task instances
        api_response = api_instance.get_task_instances(dag_id, dag_run_id, execution_date_gte=execution_date_gte, execution_date_lte=execution_date_lte, start_date_gte=start_date_gte, start_date_lte=start_date_lte, end_date_gte=end_date_gte, end_date_lte=end_date_lte, duration_gte=duration_gte, duration_lte=duration_lte, state=state, pool=pool, queue=queue, limit=limit, offset=offset)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling TaskInstanceApi->get_task_instances: %s\n" % e)

Parameters

NameTypeDescriptionNotes
dag_idstrThe DAG ID.
dag_run_idstrThe DAG run ID.
execution_date_gtedatetimeReturns objects greater or equal to the specified date. This can be combined with execution_date_lte parameter to receive only the selected period.[optional]
execution_date_ltedatetimeReturns objects less than or equal to the specified date. This can be combined with execution_date_gte parameter to receive only the selected period.[optional]
start_date_gtedatetimeReturns objects greater or equal the specified date. This can be combined with start_date_lte parameter to receive only the selected period.[optional]
start_date_ltedatetimeReturns objects less or equal the specified date. This can be combined with start_date_gte parameter to receive only the selected period.[optional]
end_date_gtedatetimeReturns objects greater or equal the specified date. This can be combined with start_date_lte parameter to receive only the selected period.[optional]
end_date_ltedatetimeReturns objects less than or equal to the specified date. This can be combined with start_date_gte parameter to receive only the selected period.[optional]
duration_gtefloatReturns objects greater than or equal to the specified values. This can be combined with duration_lte parameter to receive only the selected period.[optional]
duration_ltefloatReturns objects less than or equal to the specified values. This can be combined with duration_gte parameter to receive only the selected range.[optional]
state[str]The value can be repeated to retrieve multiple matching values (OR condition).[optional]
pool[str]The value can be repeated to retrieve multiple matching values (OR condition).[optional]
queue[str]The value can be repeated to retrieve multiple matching values (OR condition).[optional]
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

TaskInstanceCollection

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_task_instances_batch

TaskInstanceCollection get_task_instances_batch(list_task_instance_form)

List task instances (batch)

List task instances from all DAGs and DAG runs. This endpoint is a POST to allow filtering across a large number of DAG IDs, where as a GET it would run in to maximum HTTP request URL length limits.

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import task_instance_api
from airflow_client.client.model.task_instance_collection import TaskInstanceCollection
from airflow_client.client.model.error import Error
from airflow_client.client.model.list_task_instance_form import ListTaskInstanceForm
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 = task_instance_api.TaskInstanceApi(api_client)
    list_task_instance_form = ListTaskInstanceForm(
        dag_ids=[
            "dag_ids_example",
        ],
        execution_date_gte=dateutil_parser('1970-01-01T00:00:00.00Z'),
        execution_date_lte=dateutil_parser('1970-01-01T00:00:00.00Z'),
        start_date_gte=dateutil_parser('1970-01-01T00:00:00.00Z'),
        start_date_lte=dateutil_parser('1970-01-01T00:00:00.00Z'),
        end_date_gte=dateutil_parser('1970-01-01T00:00:00.00Z'),
        end_date_lte=dateutil_parser('1970-01-01T00:00:00.00Z'),
        duration_gte=3.14,
        duration_lte=3.14,
        state=[
            "state_example",
        ],
        pool=[
            "pool_example",
        ],
        queue=[
            "queue_example",
        ],
    ) # ListTaskInstanceForm | 

    # example passing only required values which don't have defaults set
    try:
        # List task instances (batch)
        api_response = api_instance.get_task_instances_batch(list_task_instance_form)
        pprint(api_response)
    except client.ApiException as e:
        print("Exception when calling TaskInstanceApi->get_task_instances_batch: %s\n" % e)

Parameters

NameTypeDescriptionNotes
list_task_instance_formListTaskInstanceForm

Return type

TaskInstanceCollection

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: application/json
  • 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]