Class Client
-
- All Implemented Interfaces:
public final class ClientClient 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.
-
-
Method Summary
Modifier and Type Method Description final ConnectiongetConnection(String id)Retrieves a connection from the Airflow connection store. final ObjectgetVariable(String key)Retrieves an Airflow variable. final ObjectgetXCom(String key, String dagId, String taskId, String runId, Integer mapIndex, Boolean includePriorDates)Reads an XCom value pushed by another task. final ObjectgetXCom(String key, String dagId, String taskId, String runId, Integer mapIndex)Reads an XCom value pushed by another task. final ObjectgetXCom(String key, String dagId, String taskId, String runId)Reads an XCom value pushed by another task. final ObjectgetXCom(String key, String dagId, String taskId)Reads an XCom value pushed by another task. final ObjectgetXCom(String key, String taskId)Reads an XCom value pushed by another task. final ObjectgetXCom(String taskId)Reads an XCom value pushed by another task. final UnitsetXCom(String key, Object value)Pushes an XCom value for downstream tasks to read. final UnitsetXCom(Object value)Pushes an XCom value for downstream tasks to read. -
-
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
nullif 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- Iftrue, also search earlier Dag-run dates.- Returns:
The XCom value, or
nullif 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
nullif 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
nullif 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
nullif 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
nullif 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
nullif 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.
-
-
-
-