Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class BulkDAGRunBody(StrictBaseModel):
dag_id: str | None = None


class DAGRunClearBody(StrictBaseModel):
"""Dag Run serializer for clear endpoint body."""
class BaseDAGRunClear(StrictBaseModel):
"""Shared options for the single-run and bulk Dag Run clear endpoints."""

dry_run: bool = True
only_failed: bool = False
Expand All @@ -68,25 +68,31 @@ class DAGRunClearBody(StrictBaseModel):
)
run_on_latest_version: bool | None = Field(
default=None,
description="(Experimental) Run on the latest bundle version of the Dag after clearing the Dag Run. "
description="(Experimental) Run on the latest bundle version of the Dag after clearing. "
"If not specified, falls back to the DAG-level ``rerun_with_latest_version`` parameter, "
"then the ``[core] rerun_with_latest_version`` config option, "
"and finally ``False`` (the historical default for clear/rerun).",
)
note: str | None = Field(
default=None,
max_length=1000,
"and finally ``False``.",
)
note: str | None = Field(default=None, max_length=1000)

@model_validator(mode="before")
@classmethod
def validate_model(cls, data: Any) -> Any:
"""Validate clear Dag run form."""
def validate_only_new_only_failed_mutually_exclusive(cls, data: Any) -> Any:
if data.get("only_new") and data.get("only_failed"):
raise ValueError("only_new and only_failed are mutually exclusive")
return data


class DAGRunClearBody(BaseDAGRunClear):
"""Dag Run serializer for clear endpoint body."""


class BulkDAGRunClearBody(BaseDAGRunClear):
"""Request body for the bulk clear Dag Runs endpoint."""

dag_runs: list[BulkDAGRunBody] = Field(min_length=1)


class DAGRunResponse(BaseModel):
"""Dag Run serializer for responses."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2980,6 +2980,69 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/api/v2/dags/{dag_id}/clearDagRuns:
post:
tags:
- DagRun
summary: Clear Dag Runs
description: Clear multiple Dag Runs in a single request.
operationId: clear_dag_runs
security:
- OAuth2PasswordBearer: []
- HTTPBearer: []
parameters:
- name: dag_id
in: path
required: true
schema:
type: string
title: Dag Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BulkDAGRunClearBody'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/ClearTaskInstanceCollectionResponse'
- $ref: '#/components/schemas/DAGRunCollectionResponse'
title: Response Clear Dag Runs
'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'
/api/v2/dagSources/{dag_id}:
get:
tags:
Expand Down Expand Up @@ -11883,6 +11946,49 @@ components:
- dag_run_id
title: BulkDAGRunBody
description: Request body for bulk delete operations on Dag Runs.
BulkDAGRunClearBody:
properties:
dry_run:
type: boolean
title: Dry Run
default: true
only_failed:
type: boolean
title: Only Failed
default: false
only_new:
type: boolean
title: Only New
description: Only queue newly added tasks in the latest Dag version without
clearing existing tasks.
default: false
run_on_latest_version:
anyOf:
- type: boolean
- type: 'null'
title: Run On Latest Version
description: (Experimental) Run on the latest bundle version of the Dag
after clearing. If not specified, falls back to the DAG-level ``rerun_with_latest_version``
parameter, then the ``[core] rerun_with_latest_version`` config option,
and finally ``False``.
note:
anyOf:
- type: string
maxLength: 1000
- type: 'null'
title: Note
dag_runs:
items:
$ref: '#/components/schemas/BulkDAGRunBody'
type: array
minItems: 1
title: Dag Runs
additionalProperties: false
type: object
required:
- dag_runs
title: BulkDAGRunClearBody
description: Request body for the bulk clear Dag Runs endpoint.
BulkDeleteAction_BulkDAGRunBody_:
properties:
action:
Expand Down Expand Up @@ -13093,9 +13199,9 @@ components:
- type: 'null'
title: Run On Latest Version
description: (Experimental) Run on the latest bundle version of the Dag
after clearing the Dag Run. If not specified, falls back to the DAG-level
``rerun_with_latest_version`` parameter, then the ``[core] rerun_with_latest_version``
config option, and finally ``False`` (the historical default for clear/rerun).
after clearing. If not specified, falls back to the DAG-level ``rerun_with_latest_version``
parameter, then the ``[core] rerun_with_latest_version`` config option,
and finally ``False``.
note:
anyOf:
- type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from airflow.api_fastapi.core_api.routes.public.config import config_router
from airflow.api_fastapi.core_api.routes.public.connections import connections_router
from airflow.api_fastapi.core_api.routes.public.dag_parsing import dag_parsing_router
from airflow.api_fastapi.core_api.routes.public.dag_run import dag_run_router
from airflow.api_fastapi.core_api.routes.public.dag_run import dag_run_at_dag_router, dag_run_router
from airflow.api_fastapi.core_api.routes.public.dag_sources import dag_sources_router
from airflow.api_fastapi.core_api.routes.public.dag_stats import dag_stats_router
from airflow.api_fastapi.core_api.routes.public.dag_tags import dag_tags_router
Expand Down Expand Up @@ -69,6 +69,7 @@
authenticated_router.include_router(backfills_router)
authenticated_router.include_router(connections_router)
authenticated_router.include_router(dag_run_router)
authenticated_router.include_router(dag_run_at_dag_router)
authenticated_router.include_router(dag_sources_router)
authenticated_router.include_router(dag_stats_router)
authenticated_router.include_router(config_router)
Expand Down
Loading
Loading