Class Client

  • All Implemented Interfaces:

    
    public final class Client
    
                        

    Client for Airflow API calls scoped to the current task instance.

    An instance is provided when a task is being executed. All reads and writes are automatically scoped to the current Dag run and task instance unless you pass explicit IDs.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • getConnection

         final Connection getConnection(String id)

        Retrieves a connection from the Airflow connection store.

        Parameters:
        id - Connection ID as configured in Airflow.
        Returns:

        The connection.

      • getVariable

         final Object getVariable(String key)

        Retrieves an Airflow variable.

        Parameters:
        key - Variable key.
        Returns:

        The variable value, or null if the variable is not set.

      • getXCom

        @JvmOverloads() final Object getXCom(String key, String dagId, String taskId, String runId, Integer mapIndex, Boolean includePriorDates)

        Reads an XCom value pushed by another task.

        The current Dag run's dagId and runId are used by default; override them only when reading across Dags or runs.

        Parameters:
        key - XCom key to read; defaults to XCOM_RETURN_KEY.
        dagId - Dag that owns the XCom; defaults to the current Dag.
        taskId - Task that pushed the XCom.
        runId - Run that produced the XCom; defaults to the current run.
        mapIndex - Map index of the source task instance.
        includePriorDates - If true, also search earlier Dag-run dates.
        Returns:

        The XCom value, or null if none was pushed.

      • getXCom

        @JvmOverloads() final Object getXCom(String key, String dagId, String taskId, String runId, Integer mapIndex)

        Reads an XCom value pushed by another task.

        The current Dag run's dagId and runId are used by default; override them only when reading across Dags or runs.

        Parameters:
        key - XCom key to read; defaults to XCOM_RETURN_KEY.
        dagId - Dag that owns the XCom; defaults to the current Dag.
        taskId - Task that pushed the XCom.
        runId - Run that produced the XCom; defaults to the current run.
        mapIndex - Map index of the source task instance.
        Returns:

        The XCom value, or null if none was pushed.

      • getXCom

        @JvmOverloads() final Object getXCom(String key, String dagId, String taskId, String runId)

        Reads an XCom value pushed by another task.

        The current Dag run's dagId and runId are used by default; override them only when reading across Dags or runs.

        Parameters:
        key - XCom key to read; defaults to XCOM_RETURN_KEY.
        dagId - Dag that owns the XCom; defaults to the current Dag.
        taskId - Task that pushed the XCom.
        runId - Run that produced the XCom; defaults to the current run.
        Returns:

        The XCom value, or null if none was pushed.

      • getXCom

        @JvmOverloads() final Object getXCom(String key, String dagId, String taskId)

        Reads an XCom value pushed by another task.

        The current Dag run's dagId and runId are used by default; override them only when reading across Dags or runs.

        Parameters:
        key - XCom key to read; defaults to XCOM_RETURN_KEY.
        dagId - Dag that owns the XCom; defaults to the current Dag.
        taskId - Task that pushed the XCom.
        Returns:

        The XCom value, or null if none was pushed.

      • getXCom

        @JvmOverloads() final Object getXCom(String key, String taskId)

        Reads an XCom value pushed by another task.

        The current Dag run's dagId and runId are used by default; override them only when reading across Dags or runs.

        Parameters:
        key - XCom key to read; defaults to XCOM_RETURN_KEY.
        taskId - Task that pushed the XCom.
        Returns:

        The XCom value, or null if none was pushed.

      • getXCom

        @JvmOverloads() final Object getXCom(String taskId)

        Reads an XCom value pushed by another task.

        The current Dag run's dagId and runId are used by default; override them only when reading across Dags or runs.

        Parameters:
        taskId - Task that pushed the XCom.
        Returns:

        The XCom value, or null if none was pushed.

      • setXCom

        @JvmOverloads() final Unit setXCom(String key, Object value)

        Pushes an XCom value for downstream tasks to read.

        Parameters:
        key - XCom key; defaults to XCOM_RETURN_KEY.
        value - Value to push.
      • setXCom

        @JvmOverloads() final Unit setXCom(Object value)

        Pushes an XCom value for downstream tasks to read.

        Parameters:
        value - Value to push.