Apache Airflow Variable API

The Variable API from Apache Airflow — 2 operation(s) for variable.

OpenAPI Specification

airflow-variable-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Airflow Asset Variable API
  description: Airflow API. All endpoints located under ``/api/v2`` can be used safely, are stable and backward compatible. Endpoints located under ``/ui`` are dedicated to the UI and are subject to breaking change depending on the need of the frontend. Users should not rely on those but use the public ones instead.
  version: '2'
tags:
- name: Variable
paths:
  /api/v2/variables/{variable_key}:
    delete:
      tags:
      - Variable
      summary: Airflow Delete Variable
      description: Delete a variable entry.
      operationId: delete_variable
      security:
      - OAuth2PasswordBearer: []
      - HTTPBearer: []
      parameters:
      - name: variable_key
        in: path
        required: true
        schema:
          type: string
          title: Variable Key
      responses:
        '204':
          description: Successful Response
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Not Found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    get:
      tags:
      - Variable
      summary: Airflow Get Variable
      description: Get a variable entry.
      operationId: get_variable
      security:
      - OAuth2PasswordBearer: []
      - HTTPBearer: []
      parameters:
      - name: variable_key
        in: path
        required: true
        schema:
          type: string
          title: Variable Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VariableResponse'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Not Found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    patch:
      tags:
      - Variable
      summary: Airflow Patch Variable
      description: Update a variable by key.
      operationId: patch_variable
      security:
      - OAuth2PasswordBearer: []
      - HTTPBearer: []
      parameters:
      - name: variable_key
        in: path
        required: true
        schema:
          type: string
          title: Variable Key
      - name: update_mask
        in: query
        required: false
        schema:
          anyOf:
          - type: array
            items:
              type: string
          - type: 'null'
          title: Update Mask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VariableBody'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VariableResponse'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Forbidden
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Bad Request
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Not Found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /api/v2/variables:
    get:
      tags:
      - Variable
      summary: Airflow Get Variables
      description: Get all Variables entries.
      operationId: get_variables
      security:
      - OAuth2PasswordBearer: []
      - HTTPBearer: []
      parameters:
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
          default: 50
          title: Limit
      - name: offset
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
          default: 0
          title: Offset
      - name: order_by
        in: query
        required: false
        schema:
          type: array
          items:
            type: string
          description: 'Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `key, id, _val, description, is_encrypted, team_name`'
          default:
          - id
          title: Order By
        description: 'Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `key, id, _val, description, is_encrypted, team_name`'
      - name: variable_key_pattern
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). or the pipe `|` operator for OR logic (e.g. `dag1 | dag2`). Regular expressions are **not** supported.
          title: Variable Key Pattern
        description: SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). or the pipe `|` operator for OR logic (e.g. `dag1 | dag2`). Regular expressions are **not** supported.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VariableCollectionResponse'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Forbidden
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    post:
      tags:
      - Variable
      summary: Airflow Post Variable
      description: Create a variable.
      operationId: post_variable
      security:
      - OAuth2PasswordBearer: []
      - HTTPBearer: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VariableBody'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VariableResponse'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Forbidden
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Conflict
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    patch:
      tags:
      - Variable
      summary: Airflow Bulk Variables
      description: Bulk create, update, and delete variables.
      operationId: bulk_variables
      security:
      - OAuth2PasswordBearer: []
      - HTTPBearer: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkBody_VariableBody_'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkResponse'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Forbidden
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  schemas:
    BulkResponse:
      properties:
        create:
          anyOf:
          - $ref: '#/components/schemas/BulkActionResponse'
          - type: 'null'
          description: Details of the bulk create operation, including successful keys and errors.
        update:
          anyOf:
          - $ref: '#/components/schemas/BulkActionResponse'
          - type: 'null'
          description: Details of the bulk update operation, including successful keys and errors.
        delete:
          anyOf:
          - $ref: '#/components/schemas/BulkActionResponse'
          - type: 'null'
          description: Details of the bulk delete operation, including successful keys and errors.
      type: object
      title: BulkResponse
      description: 'Serializer for responses to bulk entity operations.


        This represents the results of create, update, and delete actions performed on entity in bulk.

        Each action (if requested) is represented as a field containing details about successful keys and any encountered errors.

        Fields are populated in the response only if the respective action was part of the request, else are set None.'
    BulkActionNotOnExistence:
      type: string
      enum:
      - fail
      - skip
      title: BulkActionNotOnExistence
      description: Bulk Action to be taken if the entity does not exist.
    VariableCollectionResponse:
      properties:
        variables:
          items:
            $ref: '#/components/schemas/VariableResponse'
          type: array
          title: Variables
        total_entries:
          type: integer
          title: Total Entries
      type: object
      required:
      - variables
      - total_entries
      title: VariableCollectionResponse
      description: Variable Collection serializer for responses.
    BulkDeleteAction_VariableBody_:
      properties:
        action:
          type: string
          const: delete
          title: Action
          description: The action to be performed on the entities.
        entities:
          items:
            anyOf:
            - type: string
            - $ref: '#/components/schemas/VariableBody'
          type: array
          title: Entities
          description: A list of entity id/key or entity objects to be deleted.
        action_on_non_existence:
          $ref: '#/components/schemas/BulkActionNotOnExistence'
          default: fail
      additionalProperties: false
      type: object
      required:
      - action
      - entities
      title: BulkDeleteAction[VariableBody]
    BulkUpdateAction_VariableBody_:
      properties:
        action:
          type: string
          const: update
          title: Action
          description: The action to be performed on the entities.
        entities:
          items:
            $ref: '#/components/schemas/VariableBody'
          type: array
          title: Entities
          description: A list of entities to be updated.
        update_mask:
          anyOf:
          - items:
              type: string
            type: array
          - type: 'null'
          title: Update Mask
          description: A list of field names to update for each entity.Only these fields will be applied from the request body to the database model.Any extra fields provided will be ignored.
        action_on_non_existence:
          $ref: '#/components/schemas/BulkActionNotOnExistence'
          default: fail
      additionalProperties: false
      type: object
      required:
      - action
      - entities
      title: BulkUpdateAction[VariableBody]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    VariableResponse:
      properties:
        key:
          type: string
          title: Key
        value:
          type: string
          title: Value
        description:
          anyOf:
          - type: string
          - type: 'null'
          title: Description
        is_encrypted:
          type: boolean
          title: Is Encrypted
        team_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Team Name
      type: object
      required:
      - key
      - value
      - description
      - is_encrypted
      - team_name
      title: VariableResponse
      description: Variable serializer for responses.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    BulkCreateAction_VariableBody_:
      properties:
        action:
          type: string
          const: create
          title: Action
          description: The action to be performed on the entities.
        entities:
          items:
            $ref: '#/components/schemas/VariableBody'
          type: array
          title: Entities
          description: A list of entities to be created.
        action_on_existence:
          $ref: '#/components/schemas/BulkActionOnExistence'
          default: fail
      additionalProperties: false
      type: object
      required:
      - action
      - entities
      title: BulkCreateAction[VariableBody]
    VariableBody:
      properties:
        key:
          type: string
          maxLength: 250
          title: Key
        value:
          $ref: '#/components/schemas/JsonValue'
        description:
          anyOf:
          - type: string
          - type: 'null'
          title: Description
        team_name:
          anyOf:
          - type: string
            maxLength: 50
          - type: 'null'
          title: Team Name
      additionalProperties: false
      type: object
      required:
      - key
      - value
      title: VariableBody
      description: Variable serializer for bodies.
    BulkActionResponse:
      properties:
        success:
          items:
            type: string
          type: array
          title: Success
          description: A list of unique id/key representing successful operations.
          default: []
        errors:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Errors
          description: A list of errors encountered during the operation, each containing details about the issue.
          default: []
      type: object
      title: BulkActionResponse
      description: 'Serializer for individual bulk action responses.


        Represents the outcome of a single bulk operation (create, update, or delete).

        The response includes a list of successful keys and any errors encountered during the operation.

        This structure helps users understand which key actions succeeded and which failed.'
    BulkBody_VariableBody_:
      properties:
        actions:
          items:
            oneOf:
            - $ref: '#/components/schemas/BulkCreateAction_VariableBody_'
            - $ref: '#/components/schemas/BulkUpdateAction_VariableBody_'
            - $ref: '#/components/schemas/BulkDeleteAction_VariableBody_'
          type: array
          title: Actions
      additionalProperties: false
      type: object
      required:
      - actions
      title: BulkBody[VariableBody]
    HTTPExceptionResponse:
      properties:
        detail:
          anyOf:
          - type: string
          - additionalProperties: true
            type: object
          title: Detail
      type: object
      required:
      - detail
      title: HTTPExceptionResponse
      description: HTTPException Model used for error response.
    JsonValue: {}
    BulkActionOnExistence:
      type: string
      enum:
      - fail
      - skip
      - overwrite
      title: BulkActionOnExistence
      description: Bulk Action to be taken if the entity already exists or not.
  securitySchemes:
    OAuth2PasswordBearer:
      type: oauth2
      description: To authenticate Airflow API requests, clients must include a JWT (JSON Web Token) in the Authorization header of each request. This token is used to verify the identity of the client and ensure that they have the appropriate permissions to access the requested resources. You can use the endpoint ``POST /auth/token`` in order to generate a JWT token. Upon successful authentication, the server will issue a JWT token that contains the necessary information (such as user identity and scope) to authenticate subsequent requests. To learn more about Airflow public API authentication, please read https://airflow.apache.org/docs/apache-airflow/stable/security/api.html.
      flows:
        password:
          scopes: {}
          tokenUrl: /auth/token
    HTTPBearer:
      type: http
      scheme: bearer