diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index b7e7f62693719..f22d4e0be9883 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -1810,6 +1810,59 @@ paths: application/json: schema: $ref: '#/components/schemas/VersionInfo' + /public/dagStats/: + get: + tags: + - DagStats + summary: Get Dag Stats + description: Get Dag statistics. + operationId: get_dag_stats + parameters: + - name: dag_ids + in: query + required: false + schema: + type: array + items: + type: string + title: Dag Ids + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/DagStatsCollectionResponse' + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPExceptionResponse' + description: Bad Request + '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' components: schemas: AppBuilderMenuItemResponse: @@ -2729,6 +2782,51 @@ components: - asset_triggered title: DagRunType description: Class with DagRun types. + DagStatsCollectionResponse: + properties: + dags: + items: + $ref: '#/components/schemas/DagStatsResponse' + type: array + title: Dags + total_entries: + type: integer + title: Total Entries + type: object + required: + - dags + - total_entries + title: DagStatsCollectionResponse + description: DAG Stats Collection serializer for responses. + DagStatsResponse: + properties: + dag_id: + type: string + title: Dag Id + stats: + items: + $ref: '#/components/schemas/DagStatsStateResponse' + type: array + title: Stats + type: object + required: + - dag_id + - stats + title: DagStatsResponse + description: DAG Stats serializer for responses. + DagStatsStateResponse: + properties: + state: + $ref: '#/components/schemas/DagRunState' + count: + type: integer + title: Count + type: object + required: + - state + - count + title: DagStatsStateResponse + description: DagStatsState serializer for responses. DagTagPydantic: properties: name: diff --git a/airflow/ui/openapi-gen/queries/common.ts b/airflow/ui/openapi-gen/queries/common.ts index 07edb67a99304..7c8a8a47fc22a 100644 --- a/airflow/ui/openapi-gen/queries/common.ts +++ b/airflow/ui/openapi-gen/queries/common.ts @@ -7,6 +7,7 @@ import { DagRunService, DagService, DagSourceService, + DagStatsService, DagsService, DashboardService, EventLogService, @@ -500,6 +501,22 @@ export const UseVersionServiceGetVersionKeyFn = (queryKey?: Array) => [ useVersionServiceGetVersionKey, ...(queryKey ?? []), ]; +export type DagStatsServiceGetDagStatsDefaultResponse = Awaited< + ReturnType +>; +export type DagStatsServiceGetDagStatsQueryResult< + TData = DagStatsServiceGetDagStatsDefaultResponse, + TError = unknown, +> = UseQueryResult; +export const useDagStatsServiceGetDagStatsKey = "DagStatsServiceGetDagStats"; +export const UseDagStatsServiceGetDagStatsKeyFn = ( + { + dagIds, + }: { + dagIds?: string[]; + } = {}, + queryKey?: Array, +) => [useDagStatsServiceGetDagStatsKey, ...(queryKey ?? [{ dagIds }])]; export type PoolServicePostPoolMutationResult = Awaited< ReturnType >; diff --git a/airflow/ui/openapi-gen/queries/prefetch.ts b/airflow/ui/openapi-gen/queries/prefetch.ts index db61369e19ff7..acf401c5ebf7e 100644 --- a/airflow/ui/openapi-gen/queries/prefetch.ts +++ b/airflow/ui/openapi-gen/queries/prefetch.ts @@ -7,6 +7,7 @@ import { DagRunService, DagService, DagSourceService, + DagStatsService, DagsService, DashboardService, EventLogService, @@ -631,3 +632,23 @@ export const prefetchUseVersionServiceGetVersion = (queryClient: QueryClient) => queryKey: Common.UseVersionServiceGetVersionKeyFn(), queryFn: () => VersionService.getVersion(), }); +/** + * Get Dag Stats + * Get Dag statistics. + * @param data The data for the request. + * @param data.dagIds + * @returns DagStatsCollectionResponse Successful Response + * @throws ApiError + */ +export const prefetchUseDagStatsServiceGetDagStats = ( + queryClient: QueryClient, + { + dagIds, + }: { + dagIds?: string[]; + } = {}, +) => + queryClient.prefetchQuery({ + queryKey: Common.UseDagStatsServiceGetDagStatsKeyFn({ dagIds }), + queryFn: () => DagStatsService.getDagStats({ dagIds }), + }); diff --git a/airflow/ui/openapi-gen/queries/queries.ts b/airflow/ui/openapi-gen/queries/queries.ts index 7820656799e5b..0ebc20ec967b7 100644 --- a/airflow/ui/openapi-gen/queries/queries.ts +++ b/airflow/ui/openapi-gen/queries/queries.ts @@ -12,6 +12,7 @@ import { DagRunService, DagService, DagSourceService, + DagStatsService, DagsService, DashboardService, EventLogService, @@ -808,6 +809,32 @@ export const useVersionServiceGetVersion = < queryFn: () => VersionService.getVersion() as TData, ...options, }); +/** + * Get Dag Stats + * Get Dag statistics. + * @param data The data for the request. + * @param data.dagIds + * @returns DagStatsCollectionResponse Successful Response + * @throws ApiError + */ +export const useDagStatsServiceGetDagStats = < + TData = Common.DagStatsServiceGetDagStatsDefaultResponse, + TError = unknown, + TQueryKey extends Array = unknown[], +>( + { + dagIds, + }: { + dagIds?: string[]; + } = {}, + queryKey?: TQueryKey, + options?: Omit, "queryKey" | "queryFn">, +) => + useQuery({ + queryKey: Common.UseDagStatsServiceGetDagStatsKeyFn({ dagIds }, queryKey), + queryFn: () => DagStatsService.getDagStats({ dagIds }) as TData, + ...options, + }); /** * Post Pool * Create a Pool. diff --git a/airflow/ui/openapi-gen/queries/suspense.ts b/airflow/ui/openapi-gen/queries/suspense.ts index 2cb0841d71f28..fb8380269d5cd 100644 --- a/airflow/ui/openapi-gen/queries/suspense.ts +++ b/airflow/ui/openapi-gen/queries/suspense.ts @@ -7,6 +7,7 @@ import { DagRunService, DagService, DagSourceService, + DagStatsService, DagsService, DashboardService, EventLogService, @@ -796,3 +797,29 @@ export const useVersionServiceGetVersionSuspense = < queryFn: () => VersionService.getVersion() as TData, ...options, }); +/** + * Get Dag Stats + * Get Dag statistics. + * @param data The data for the request. + * @param data.dagIds + * @returns DagStatsCollectionResponse Successful Response + * @throws ApiError + */ +export const useDagStatsServiceGetDagStatsSuspense = < + TData = Common.DagStatsServiceGetDagStatsDefaultResponse, + TError = unknown, + TQueryKey extends Array = unknown[], +>( + { + dagIds, + }: { + dagIds?: string[]; + } = {}, + queryKey?: TQueryKey, + options?: Omit, "queryKey" | "queryFn">, +) => + useSuspenseQuery({ + queryKey: Common.UseDagStatsServiceGetDagStatsKeyFn({ dagIds }, queryKey), + queryFn: () => DagStatsService.getDagStats({ dagIds }) as TData, + ...options, + }); diff --git a/airflow/ui/openapi-gen/requests/schemas.gen.ts b/airflow/ui/openapi-gen/requests/schemas.gen.ts index 712cc8cae984e..92e4fc5bb7b4d 100644 --- a/airflow/ui/openapi-gen/requests/schemas.gen.ts +++ b/airflow/ui/openapi-gen/requests/schemas.gen.ts @@ -1465,6 +1465,62 @@ export const $DagRunType = { description: "Class with DagRun types.", } as const; +export const $DagStatsCollectionResponse = { + properties: { + dags: { + items: { + $ref: "#/components/schemas/DagStatsResponse", + }, + type: "array", + title: "Dags", + }, + total_entries: { + type: "integer", + title: "Total Entries", + }, + }, + type: "object", + required: ["dags", "total_entries"], + title: "DagStatsCollectionResponse", + description: "DAG Stats Collection serializer for responses.", +} as const; + +export const $DagStatsResponse = { + properties: { + dag_id: { + type: "string", + title: "Dag Id", + }, + stats: { + items: { + $ref: "#/components/schemas/DagStatsStateResponse", + }, + type: "array", + title: "Stats", + }, + }, + type: "object", + required: ["dag_id", "stats"], + title: "DagStatsResponse", + description: "DAG Stats serializer for responses.", +} as const; + +export const $DagStatsStateResponse = { + properties: { + state: { + $ref: "#/components/schemas/DagRunState", + }, + count: { + type: "integer", + title: "Count", + }, + }, + type: "object", + required: ["state", "count"], + title: "DagStatsStateResponse", + description: "DagStatsState serializer for responses.", +} as const; + export const $DagTagPydantic = { properties: { name: { diff --git a/airflow/ui/openapi-gen/requests/services.gen.ts b/airflow/ui/openapi-gen/requests/services.gen.ts index 486e04b056f8a..aebc49a4b2c5d 100644 --- a/airflow/ui/openapi-gen/requests/services.gen.ts +++ b/airflow/ui/openapi-gen/requests/services.gen.ts @@ -69,6 +69,8 @@ import type { PostVariableData, PostVariableResponse, GetVersionResponse, + GetDagStatsData, + GetDagStatsResponse, } from "./types.gen"; export class AssetService { @@ -1065,3 +1067,32 @@ export class VersionService { }); } } + +export class DagStatsService { + /** + * Get Dag Stats + * Get Dag statistics. + * @param data The data for the request. + * @param data.dagIds + * @returns DagStatsCollectionResponse Successful Response + * @throws ApiError + */ + public static getDagStats( + data: GetDagStatsData = {}, + ): CancelablePromise { + return __request(OpenAPI, { + method: "GET", + url: "/public/dagStats/", + query: { + dag_ids: data.dagIds, + }, + errors: { + 400: "Bad Request", + 401: "Unauthorized", + 403: "Forbidden", + 404: "Not Found", + 422: "Validation Error", + }, + }); + } +} diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index 0580694ba78f0..0736d47251460 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -304,6 +304,30 @@ export type DagRunType = | "manual" | "asset_triggered"; +/** + * DAG Stats Collection serializer for responses. + */ +export type DagStatsCollectionResponse = { + dags: Array; + total_entries: number; +}; + +/** + * DAG Stats serializer for responses. + */ +export type DagStatsResponse = { + dag_id: string; + stats: Array; +}; + +/** + * DagStatsState serializer for responses. + */ +export type DagStatsStateResponse = { + state: DagRunState; + count: number; +}; + /** * Serializable representation of the DagTag ORM SqlAlchemyModel used by internal API. */ @@ -872,6 +896,12 @@ export type PostVariableResponse = VariableResponse; export type GetVersionResponse = VersionInfo; +export type GetDagStatsData = { + dagIds?: Array; +}; + +export type GetDagStatsResponse = DagStatsCollectionResponse; + export type $OpenApiTs = { "/ui/next_run_assets/{dag_id}": { get: { @@ -1699,4 +1729,35 @@ export type $OpenApiTs = { }; }; }; + "/public/dagStats/": { + get: { + req: GetDagStatsData; + res: { + /** + * Successful Response + */ + 200: DagStatsCollectionResponse; + /** + * Bad Request + */ + 400: HTTPExceptionResponse; + /** + * Unauthorized + */ + 401: HTTPExceptionResponse; + /** + * Forbidden + */ + 403: HTTPExceptionResponse; + /** + * Not Found + */ + 404: HTTPExceptionResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + }; };