diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index d85deb8aa096a..bbe315c3223e0 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -715,32 +715,32 @@ paths: schema: $ref: '#/components/schemas/HTTPExceptionResponse' description: Unprocessable Entity - /public/dagSources/{file_token}: + /public/dags/{dag_id}/dagRuns/{dag_run_id}: get: tags: - - DagSource - summary: Get Dag Source - description: Get source code using file token. - operationId: get_dag_source + - DagRun + summary: Get Dag Run + operationId: get_dag_run parameters: - - name: file_token + - name: dag_id in: path required: true schema: type: string - title: File Token + title: Dag Id + - name: dag_run_id + in: path + required: true + schema: + type: string + title: Dag Run Id responses: '200': description: Successful Response - content: - application/json: - schema: {} - '400': content: application/json: schema: - $ref: '#/components/schemas/HTTPExceptionResponse' - description: Bad Request + $ref: '#/components/schemas/DAGRunResponse' '401': content: application/json: @@ -760,41 +760,39 @@ paths: $ref: '#/components/schemas/HTTPExceptionResponse' description: Not Found '422': + description: Validation Error content: application/json: schema: - $ref: '#/components/schemas/HTTPExceptionResponse' - description: Unprocessable Entity - /public/monitor/health: - get: - tags: - - Monitor - summary: Get Health - operationId: get_health - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/HealthInfoSchema' - /public/variables/{variable_key}: + $ref: '#/components/schemas/HTTPValidationError' delete: tags: - - Variable - summary: Delete Variable - description: Delete a variable entry. - operationId: delete_variable + - DagRun + summary: Delete Dag Run + description: Delete a DAG Run entry. + operationId: delete_dag_run parameters: - - name: variable_key + - name: dag_id in: path required: true schema: type: string - title: Variable Key + title: Dag Id + - name: dag_run_id + in: path + required: true + schema: + type: string + title: Dag Run Id responses: '204': description: Successful Response + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPExceptionResponse' + description: Bad Request '401': content: application/json: @@ -819,26 +817,32 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' + /public/dagSources/{file_token}: get: tags: - - Variable - summary: Get Variable - description: Get a variable entry. - operationId: get_variable + - DagSource + summary: Get Dag Source + description: Get source code using file token. + operationId: get_dag_source parameters: - - name: variable_key + - name: file_token in: path required: true schema: type: string - title: Variable Key + title: File Token responses: '200': description: Successful Response + content: + application/json: + schema: {} + '400': content: application/json: schema: - $ref: '#/components/schemas/VariableResponse' + $ref: '#/components/schemas/HTTPExceptionResponse' + description: Bad Request '401': content: application/json: @@ -858,47 +862,41 @@ paths: $ref: '#/components/schemas/HTTPExceptionResponse' description: Not Found '422': - description: Validation Error content: application/json: schema: - $ref: '#/components/schemas/HTTPValidationError' - patch: + $ref: '#/components/schemas/HTTPExceptionResponse' + description: Unprocessable Entity + /public/monitor/health: + get: tags: - - Variable - summary: Patch Variable - description: Update a variable by key. - operationId: patch_variable + - Monitor + summary: Get Health + operationId: get_health + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/HealthInfoSchema' + /public/pools/{pool_name}: + delete: + tags: + - Pool + summary: Delete Pool + description: Delete a pool entry. + operationId: delete_pool parameters: - - name: variable_key + - name: pool_name 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' + title: Pool Name responses: - '200': + '204': description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/VariableResponse' '400': content: application/json: @@ -929,42 +927,26 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' - /public/variables/: get: tags: - - Variable - summary: Get Variables - description: Get all Variables entries. - operationId: get_variables + - Pool + summary: Get Pool + description: Get a pool. + operationId: get_pool parameters: - - name: limit - in: query - required: false - schema: - type: integer - default: 100 - title: Limit - - name: offset - in: query - required: false - schema: - type: integer - default: 0 - title: Offset - - name: order_by - in: query - required: false + - name: pool_name + in: path + required: true schema: type: string - default: id - title: Order By + title: Pool Name responses: '200': description: Successful Response content: application/json: schema: - $ref: '#/components/schemas/VariableCollectionResponse' + $ref: '#/components/schemas/PoolResponse' '401': content: application/json: @@ -977,75 +959,70 @@ paths: 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' - post: + /public/providers/: + get: tags: - - Variable - summary: Post Variable - description: Create a variable. - operationId: post_variable - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/VariableBody' + - Provider + summary: Get Providers + description: Get providers. + operationId: get_providers + parameters: + - name: limit + in: query + required: false + schema: + type: integer + default: 100 + title: Limit + - name: offset + in: query + required: false + schema: + type: integer + default: 0 + title: Offset responses: - '201': + '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 + $ref: '#/components/schemas/ProviderCollectionResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' - /public/dags/{dag_id}/dagRuns/{dag_run_id}: - get: + /public/variables/{variable_key}: + delete: tags: - - DagRun - summary: Get Dag Run - operationId: get_dag_run + - Variable + summary: Delete Variable + description: Delete a variable entry. + operationId: delete_variable parameters: - - name: dag_id - in: path - required: true - schema: - type: string - title: Dag Id - - name: dag_run_id + - name: variable_key in: path required: true schema: type: string - title: Dag Run Id + title: Variable Key responses: - '200': + '204': description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/DAGRunResponse' '401': content: application/json: @@ -1070,34 +1047,26 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' - delete: + get: tags: - - DagRun - summary: Delete Dag Run - description: Delete a DAG Run entry. - operationId: delete_dag_run + - Variable + summary: Get Variable + description: Get a variable entry. + operationId: get_variable parameters: - - name: dag_id - in: path - required: true - schema: - type: string - title: Dag Id - - name: dag_run_id + - name: variable_key in: path required: true schema: type: string - title: Dag Run Id + title: Variable Key responses: - '204': + '200': description: Successful Response - '400': content: application/json: schema: - $ref: '#/components/schemas/HTTPExceptionResponse' - description: Bad Request + $ref: '#/components/schemas/VariableResponse' '401': content: application/json: @@ -1122,36 +1091,42 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' - /public/monitor/health: - get: - tags: - - Monitor - summary: Get Health - operationId: get_health - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/HealthInfoSchema' - /public/pools/{pool_name}: - delete: + patch: tags: - - Pool - summary: Delete Pool - description: Delete a pool entry. - operationId: delete_pool + - Variable + summary: Patch Variable + description: Update a variable by key. + operationId: patch_variable parameters: - - name: pool_name + - name: variable_key in: path required: true schema: type: string - title: Pool Name + 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: - '204': + '200': description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/VariableResponse' '400': content: application/json: @@ -1182,26 +1157,42 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' + /public/variables/: get: tags: - - Pool - summary: Get Pool - description: Get a pool. - operationId: get_pool + - Variable + summary: Get Variables + description: Get all Variables entries. + operationId: get_variables parameters: - - name: pool_name - in: path - required: true + - name: limit + in: query + required: false + schema: + type: integer + default: 100 + title: Limit + - name: offset + in: query + required: false + schema: + type: integer + default: 0 + title: Offset + - name: order_by + in: query + required: false schema: type: string - title: Pool Name + default: id + title: Order By responses: '200': description: Successful Response content: application/json: schema: - $ref: '#/components/schemas/PoolResponse' + $ref: '#/components/schemas/VariableCollectionResponse' '401': content: application/json: @@ -1214,47 +1205,43 @@ paths: 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' - /public/providers/: - get: + post: tags: - - Provider - summary: Get Providers - description: Get providers. - operationId: get_providers - parameters: - - name: limit - in: query - required: false - schema: - type: integer - default: 100 - title: Limit - - name: offset - in: query - required: false - schema: - type: integer - default: 0 - title: Offset + - Variable + summary: Post Variable + description: Create a variable. + operationId: post_variable + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/VariableBody' responses: - '200': + '201': description: Successful Response content: application/json: schema: - $ref: '#/components/schemas/ProviderCollectionResponse' + $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 '422': description: Validation Error content: diff --git a/airflow/api_fastapi/core_api/routes/public/dag_sources.py b/airflow/api_fastapi/core_api/routes/public/dag_sources.py index 28dfaa8d61e82..ec11e9b7323e5 100644 --- a/airflow/api_fastapi/core_api/routes/public/dag_sources.py +++ b/airflow/api_fastapi/core_api/routes/public/dag_sources.py @@ -30,16 +30,6 @@ dag_sources_router = AirflowRouter(tags=["DagSource"], prefix="/dagSources") mime_type_text = "text/plain" mime_type_json = "application/json" -supported_mime_types = [mime_type_text, mime_type_json] - - -def _get_matching_mime_type(request: Request) -> str | None: - """Return the matching MIME type in the request's ACCEPT header.""" - accept_header = request.headers.get("Accept", "").lower() - for mime_type in supported_mime_types: - if mime_type in accept_header: - return mime_type - return None @dag_sources_router.get( @@ -50,22 +40,21 @@ async def get_dag_source( file_token: str, session: Annotated[Session, Depends(get_session)], request: Request, -) -> Response: +): """Get source code using file token.""" auth_s = URLSafeSerializer(request.app.state.secret_key) try: path = auth_s.loads(file_token) - dag_source = DagCode.code(path, session=session) + dag_source_model = DAGSourceModel( + content=DagCode.code(path, session=session), + ) except (BadSignature, FileNotFoundError): raise HTTPException(404, "DAG source not found") - return_type = _get_matching_mime_type(request) - - if return_type == mime_type_text: - return Response(dag_source, media_type=return_type) - - if return_type == mime_type_json: - return Response(DAGSourceModel(content=dag_source), media_type=return_type) - + accept_header = request.headers.get("Accept", "").lower() + if accept_header.startswith(mime_type_text): + return Response(dag_source_model.content, media_type=mime_type_text) + if accept_header.startswith(mime_type_json): + return dag_source_model raise HTTPException(406, "Content not available for Accept header") diff --git a/airflow/ui/openapi-gen/queries/common.ts b/airflow/ui/openapi-gen/queries/common.ts index fdc3201743b3a..00a209a1e039e 100644 --- a/airflow/ui/openapi-gen/queries/common.ts +++ b/airflow/ui/openapi-gen/queries/common.ts @@ -251,6 +251,40 @@ export const UseMonitorServiceGetHealthKeyFn = (queryKey?: Array) => [ useMonitorServiceGetHealthKey, ...(queryKey ?? []), ]; +export type PoolServiceGetPoolDefaultResponse = Awaited< + ReturnType +>; +export type PoolServiceGetPoolQueryResult< + TData = PoolServiceGetPoolDefaultResponse, + TError = unknown, +> = UseQueryResult; +export const usePoolServiceGetPoolKey = "PoolServiceGetPool"; +export const UsePoolServiceGetPoolKeyFn = ( + { + poolName, + }: { + poolName: string; + }, + queryKey?: Array, +) => [usePoolServiceGetPoolKey, ...(queryKey ?? [{ poolName }])]; +export type ProviderServiceGetProvidersDefaultResponse = Awaited< + ReturnType +>; +export type ProviderServiceGetProvidersQueryResult< + TData = ProviderServiceGetProvidersDefaultResponse, + TError = unknown, +> = UseQueryResult; +export const useProviderServiceGetProvidersKey = "ProviderServiceGetProviders"; +export const UseProviderServiceGetProvidersKeyFn = ( + { + limit, + offset, + }: { + limit?: number; + offset?: number; + } = {}, + queryKey?: Array, +) => [useProviderServiceGetProvidersKey, ...(queryKey ?? [{ limit, offset }])]; export type VariableServiceGetVariableDefaultResponse = Awaited< ReturnType >; @@ -290,40 +324,6 @@ export const UseVariableServiceGetVariablesKeyFn = ( useVariableServiceGetVariablesKey, ...(queryKey ?? [{ limit, offset, orderBy }]), ]; -export type PoolServiceGetPoolDefaultResponse = Awaited< - ReturnType ->; -export type PoolServiceGetPoolQueryResult< - TData = PoolServiceGetPoolDefaultResponse, - TError = unknown, -> = UseQueryResult; -export const usePoolServiceGetPoolKey = "PoolServiceGetPool"; -export const UsePoolServiceGetPoolKeyFn = ( - { - poolName, - }: { - poolName: string; - }, - queryKey?: Array, -) => [usePoolServiceGetPoolKey, ...(queryKey ?? [{ poolName }])]; -export type ProviderServiceGetProvidersDefaultResponse = Awaited< - ReturnType ->; -export type ProviderServiceGetProvidersQueryResult< - TData = ProviderServiceGetProvidersDefaultResponse, - TError = unknown, -> = UseQueryResult; -export const useProviderServiceGetProvidersKey = "ProviderServiceGetProviders"; -export const UseProviderServiceGetProvidersKeyFn = ( - { - limit, - offset, - }: { - limit?: number; - offset?: number; - } = {}, - queryKey?: Array, -) => [useProviderServiceGetProvidersKey, ...(queryKey ?? [{ limit, offset }])]; export type VariableServicePostVariableMutationResult = Awaited< ReturnType >; @@ -348,3 +348,6 @@ export type DagRunServiceDeleteDagRunMutationResult = Awaited< export type PoolServiceDeletePoolMutationResult = Awaited< ReturnType >; +export type VariableServiceDeleteVariableMutationResult = Awaited< + ReturnType +>; diff --git a/airflow/ui/openapi-gen/queries/prefetch.ts b/airflow/ui/openapi-gen/queries/prefetch.ts index 5bc19691fff23..c89f4a314c2ee 100644 --- a/airflow/ui/openapi-gen/queries/prefetch.ts +++ b/airflow/ui/openapi-gen/queries/prefetch.ts @@ -309,95 +309,95 @@ export const prefetchUseMonitorServiceGetHealth = (queryClient: QueryClient) => queryFn: () => MonitorService.getHealth(), }); /** - * Get Variable - * Get a variable entry. + * Get Pool + * Get a pool. * @param data The data for the request. - * @param data.variableKey - * @returns VariableResponse Successful Response + * @param data.poolName + * @returns PoolResponse Successful Response * @throws ApiError */ -export const prefetchUseVariableServiceGetVariable = ( +export const prefetchUsePoolServiceGetPool = ( queryClient: QueryClient, { - variableKey, + poolName, }: { - variableKey: string; + poolName: string; }, ) => queryClient.prefetchQuery({ - queryKey: Common.UseVariableServiceGetVariableKeyFn({ variableKey }), - queryFn: () => VariableService.getVariable({ variableKey }), + queryKey: Common.UsePoolServiceGetPoolKeyFn({ poolName }), + queryFn: () => PoolService.getPool({ poolName }), }); /** - * Get Variables - * Get all Variables entries. + * Get Providers + * Get providers. * @param data The data for the request. * @param data.limit * @param data.offset - * @param data.orderBy - * @returns VariableCollectionResponse Successful Response + * @returns ProviderCollectionResponse Successful Response * @throws ApiError */ -export const prefetchUseVariableServiceGetVariables = ( +export const prefetchUseProviderServiceGetProviders = ( queryClient: QueryClient, { limit, offset, - orderBy, }: { limit?: number; offset?: number; - orderBy?: string; } = {}, ) => queryClient.prefetchQuery({ - queryKey: Common.UseVariableServiceGetVariablesKeyFn({ - limit, - offset, - orderBy, - }), - queryFn: () => VariableService.getVariables({ limit, offset, orderBy }), + queryKey: Common.UseProviderServiceGetProvidersKeyFn({ limit, offset }), + queryFn: () => ProviderService.getProviders({ limit, offset }), }); /** - * Get Pool - * Get a pool. + * Get Variable + * Get a variable entry. * @param data The data for the request. - * @param data.poolName - * @returns PoolResponse Successful Response + * @param data.variableKey + * @returns VariableResponse Successful Response * @throws ApiError */ -export const prefetchUsePoolServiceGetPool = ( +export const prefetchUseVariableServiceGetVariable = ( queryClient: QueryClient, { - poolName, + variableKey, }: { - poolName: string; + variableKey: string; }, ) => queryClient.prefetchQuery({ - queryKey: Common.UsePoolServiceGetPoolKeyFn({ poolName }), - queryFn: () => PoolService.getPool({ poolName }), + queryKey: Common.UseVariableServiceGetVariableKeyFn({ variableKey }), + queryFn: () => VariableService.getVariable({ variableKey }), }); /** - * Get Providers - * Get providers. + * Get Variables + * Get all Variables entries. * @param data The data for the request. * @param data.limit * @param data.offset - * @returns ProviderCollectionResponse Successful Response + * @param data.orderBy + * @returns VariableCollectionResponse Successful Response * @throws ApiError */ -export const prefetchUseProviderServiceGetProviders = ( +export const prefetchUseVariableServiceGetVariables = ( queryClient: QueryClient, { limit, offset, + orderBy, }: { limit?: number; offset?: number; + orderBy?: string; } = {}, ) => queryClient.prefetchQuery({ - queryKey: Common.UseProviderServiceGetProvidersKeyFn({ limit, offset }), - queryFn: () => ProviderService.getProviders({ limit, offset }), + queryKey: Common.UseVariableServiceGetVariablesKeyFn({ + limit, + offset, + orderBy, + }), + queryFn: () => VariableService.getVariables({ limit, offset, orderBy }), }); diff --git a/airflow/ui/openapi-gen/queries/queries.ts b/airflow/ui/openapi-gen/queries/queries.ts index eab772034c7de..4297a4a9c01df 100644 --- a/airflow/ui/openapi-gen/queries/queries.ts +++ b/airflow/ui/openapi-gen/queries/queries.ts @@ -398,131 +398,129 @@ export const useMonitorServiceGetHealth = < ...options, }); /** - * Get Variable - * Get a variable entry. + * Get Pool + * Get a pool. * @param data The data for the request. - * @param data.variableKey - * @returns VariableResponse Successful Response + * @param data.poolName + * @returns PoolResponse Successful Response * @throws ApiError */ -export const useVariableServiceGetVariable = < - TData = Common.VariableServiceGetVariableDefaultResponse, +export const usePoolServiceGetPool = < + TData = Common.PoolServiceGetPoolDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { - variableKey, + poolName, }: { - variableKey: string; + poolName: string; }, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useQuery({ - queryKey: Common.UseVariableServiceGetVariableKeyFn( - { variableKey }, - queryKey, - ), - queryFn: () => VariableService.getVariable({ variableKey }) as TData, + queryKey: Common.UsePoolServiceGetPoolKeyFn({ poolName }, queryKey), + queryFn: () => PoolService.getPool({ poolName }) as TData, ...options, }); /** - * Get Variables - * Get all Variables entries. + * Get Providers + * Get providers. * @param data The data for the request. * @param data.limit * @param data.offset - * @param data.orderBy - * @returns VariableCollectionResponse Successful Response + * @returns ProviderCollectionResponse Successful Response * @throws ApiError */ -export const useVariableServiceGetVariables = < - TData = Common.VariableServiceGetVariablesDefaultResponse, +export const useProviderServiceGetProviders = < + TData = Common.ProviderServiceGetProvidersDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { limit, offset, - orderBy, }: { limit?: number; offset?: number; - orderBy?: string; } = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useQuery({ - queryKey: Common.UseVariableServiceGetVariablesKeyFn( - { limit, offset, orderBy }, + queryKey: Common.UseProviderServiceGetProvidersKeyFn( + { limit, offset }, queryKey, ), - queryFn: () => - VariableService.getVariables({ limit, offset, orderBy }) as TData, + queryFn: () => ProviderService.getProviders({ limit, offset }) as TData, ...options, }); /** - * Get Pool - * Get a pool. + * Get Variable + * Get a variable entry. * @param data The data for the request. - * @param data.poolName - * @returns PoolResponse Successful Response + * @param data.variableKey + * @returns VariableResponse Successful Response * @throws ApiError */ -export const usePoolServiceGetPool = < - TData = Common.PoolServiceGetPoolDefaultResponse, +export const useVariableServiceGetVariable = < + TData = Common.VariableServiceGetVariableDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { - poolName, + variableKey, }: { - poolName: string; + variableKey: string; }, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useQuery({ - queryKey: Common.UsePoolServiceGetPoolKeyFn({ poolName }, queryKey), - queryFn: () => PoolService.getPool({ poolName }) as TData, + queryKey: Common.UseVariableServiceGetVariableKeyFn( + { variableKey }, + queryKey, + ), + queryFn: () => VariableService.getVariable({ variableKey }) as TData, ...options, }); /** - * Get Providers - * Get providers. + * Get Variables + * Get all Variables entries. * @param data The data for the request. * @param data.limit * @param data.offset - * @returns ProviderCollectionResponse Successful Response + * @param data.orderBy + * @returns VariableCollectionResponse Successful Response * @throws ApiError */ -export const useProviderServiceGetProviders = < - TData = Common.ProviderServiceGetProvidersDefaultResponse, +export const useVariableServiceGetVariables = < + TData = Common.VariableServiceGetVariablesDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { limit, offset, + orderBy, }: { limit?: number; offset?: number; + orderBy?: string; } = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useQuery({ - queryKey: Common.UseProviderServiceGetProvidersKeyFn( - { limit, offset }, + queryKey: Common.UseVariableServiceGetVariablesKeyFn( + { limit, offset, orderBy }, queryKey, ), - queryFn: () => ProviderService.getProviders({ limit, offset }) as TData, + queryFn: () => + VariableService.getVariables({ limit, offset, orderBy }) as TData, ...options, }); /** -======= ->>>>>>> Stashed changes * Post Variable * Create a variable. * @param data The data for the request. @@ -897,3 +895,42 @@ export const usePoolServiceDeletePool = < PoolService.deletePool({ poolName }) as unknown as Promise, ...options, }); +/** + * Delete Variable + * Delete a variable entry. + * @param data The data for the request. + * @param data.variableKey + * @returns void Successful Response + * @throws ApiError + */ +export const useVariableServiceDeleteVariable = < + TData = Common.VariableServiceDeleteVariableMutationResult, + TError = unknown, + TContext = unknown, +>( + options?: Omit< + UseMutationOptions< + TData, + TError, + { + variableKey: string; + }, + TContext + >, + "mutationFn" + >, +) => + useMutation< + TData, + TError, + { + variableKey: string; + }, + TContext + >({ + mutationFn: ({ variableKey }) => + VariableService.deleteVariable({ + variableKey, + }) as unknown as Promise, + ...options, + }); diff --git a/airflow/ui/openapi-gen/queries/suspense.ts b/airflow/ui/openapi-gen/queries/suspense.ts index 7e5800969239b..45e4fcebd3c1e 100644 --- a/airflow/ui/openapi-gen/queries/suspense.ts +++ b/airflow/ui/openapi-gen/queries/suspense.ts @@ -393,125 +393,125 @@ export const useMonitorServiceGetHealthSuspense = < ...options, }); /** - * Get Variable - * Get a variable entry. + * Get Pool + * Get a pool. * @param data The data for the request. - * @param data.variableKey - * @returns VariableResponse Successful Response + * @param data.poolName + * @returns PoolResponse Successful Response * @throws ApiError */ -export const useVariableServiceGetVariableSuspense = < - TData = Common.VariableServiceGetVariableDefaultResponse, +export const usePoolServiceGetPoolSuspense = < + TData = Common.PoolServiceGetPoolDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { - variableKey, + poolName, }: { - variableKey: string; + poolName: string; }, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useSuspenseQuery({ - queryKey: Common.UseVariableServiceGetVariableKeyFn( - { variableKey }, - queryKey, - ), - queryFn: () => VariableService.getVariable({ variableKey }) as TData, + queryKey: Common.UsePoolServiceGetPoolKeyFn({ poolName }, queryKey), + queryFn: () => PoolService.getPool({ poolName }) as TData, ...options, }); /** - * Get Variables - * Get all Variables entries. + * Get Providers + * Get providers. * @param data The data for the request. * @param data.limit * @param data.offset - * @param data.orderBy - * @returns VariableCollectionResponse Successful Response + * @returns ProviderCollectionResponse Successful Response * @throws ApiError */ -export const useVariableServiceGetVariablesSuspense = < - TData = Common.VariableServiceGetVariablesDefaultResponse, +export const useProviderServiceGetProvidersSuspense = < + TData = Common.ProviderServiceGetProvidersDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { limit, offset, - orderBy, }: { limit?: number; offset?: number; - orderBy?: string; } = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useSuspenseQuery({ - queryKey: Common.UseVariableServiceGetVariablesKeyFn( - { limit, offset, orderBy }, + queryKey: Common.UseProviderServiceGetProvidersKeyFn( + { limit, offset }, queryKey, ), - queryFn: () => - VariableService.getVariables({ limit, offset, orderBy }) as TData, + queryFn: () => ProviderService.getProviders({ limit, offset }) as TData, ...options, }); /** - * Get Pool - * Get a pool. + * Get Variable + * Get a variable entry. * @param data The data for the request. - * @param data.poolName - * @returns PoolResponse Successful Response + * @param data.variableKey + * @returns VariableResponse Successful Response * @throws ApiError */ -export const usePoolServiceGetPoolSuspense = < - TData = Common.PoolServiceGetPoolDefaultResponse, +export const useVariableServiceGetVariableSuspense = < + TData = Common.VariableServiceGetVariableDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { - poolName, + variableKey, }: { - poolName: string; + variableKey: string; }, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useSuspenseQuery({ - queryKey: Common.UsePoolServiceGetPoolKeyFn({ poolName }, queryKey), - queryFn: () => PoolService.getPool({ poolName }) as TData, + queryKey: Common.UseVariableServiceGetVariableKeyFn( + { variableKey }, + queryKey, + ), + queryFn: () => VariableService.getVariable({ variableKey }) as TData, ...options, }); /** - * Get Providers - * Get providers. + * Get Variables + * Get all Variables entries. * @param data The data for the request. * @param data.limit * @param data.offset - * @returns ProviderCollectionResponse Successful Response + * @param data.orderBy + * @returns VariableCollectionResponse Successful Response * @throws ApiError */ -export const useProviderServiceGetProvidersSuspense = < - TData = Common.ProviderServiceGetProvidersDefaultResponse, +export const useVariableServiceGetVariablesSuspense = < + TData = Common.VariableServiceGetVariablesDefaultResponse, TError = unknown, TQueryKey extends Array = unknown[], >( { limit, offset, + orderBy, }: { limit?: number; offset?: number; + orderBy?: string; } = {}, queryKey?: TQueryKey, options?: Omit, "queryKey" | "queryFn">, ) => useSuspenseQuery({ - queryKey: Common.UseProviderServiceGetProvidersKeyFn( - { limit, offset }, + queryKey: Common.UseVariableServiceGetVariablesKeyFn( + { limit, offset, orderBy }, queryKey, ), - queryFn: () => ProviderService.getProviders({ limit, offset }) as TData, + queryFn: () => + VariableService.getVariables({ limit, offset, orderBy }) as TData, ...options, }); diff --git a/airflow/ui/openapi-gen/requests/services.gen.ts b/airflow/ui/openapi-gen/requests/services.gen.ts index 301f089a198b8..69adf5878848f 100644 --- a/airflow/ui/openapi-gen/requests/services.gen.ts +++ b/airflow/ui/openapi-gen/requests/services.gen.ts @@ -34,6 +34,12 @@ import type { GetDagSourceData, GetDagSourceResponse, GetHealthResponse, + DeletePoolData, + DeletePoolResponse, + GetPoolData, + GetPoolResponse, + GetProvidersData, + GetProvidersResponse, DeleteVariableData, DeleteVariableResponse, GetVariableData, @@ -44,12 +50,6 @@ import type { GetVariablesResponse, PostVariableData, PostVariableResponse, - DeletePoolData, - DeletePoolResponse, - GetPoolData, - GetPoolResponse, - GetProvidersData, - GetProvidersResponse, } from "./types.gen"; export class AssetService { @@ -522,6 +522,86 @@ export class MonitorService { } } +export class PoolService { + /** + * Delete Pool + * Delete a pool entry. + * @param data The data for the request. + * @param data.poolName + * @returns void Successful Response + * @throws ApiError + */ + public static deletePool( + data: DeletePoolData, + ): CancelablePromise { + return __request(OpenAPI, { + method: "DELETE", + url: "/public/pools/{pool_name}", + path: { + pool_name: data.poolName, + }, + errors: { + 400: "Bad Request", + 401: "Unauthorized", + 403: "Forbidden", + 404: "Not Found", + 422: "Validation Error", + }, + }); + } + + /** + * Get Pool + * Get a pool. + * @param data The data for the request. + * @param data.poolName + * @returns PoolResponse Successful Response + * @throws ApiError + */ + public static getPool(data: GetPoolData): CancelablePromise { + return __request(OpenAPI, { + method: "GET", + url: "/public/pools/{pool_name}", + path: { + pool_name: data.poolName, + }, + errors: { + 401: "Unauthorized", + 403: "Forbidden", + 404: "Not Found", + 422: "Validation Error", + }, + }); + } +} + +export class ProviderService { + /** + * Get Providers + * Get providers. + * @param data The data for the request. + * @param data.limit + * @param data.offset + * @returns ProviderCollectionResponse Successful Response + * @throws ApiError + */ + public static getProviders( + data: GetProvidersData = {}, + ): CancelablePromise { + return __request(OpenAPI, { + method: "GET", + url: "/public/providers/", + query: { + limit: data.limit, + offset: data.offset, + }, + errors: { + 422: "Validation Error", + }, + }); + } +} + export class VariableService { /** * Delete Variable diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index f29ffe5dba7c1..d186285a25327 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -488,6 +488,25 @@ export type GetDagSourceResponse = unknown; export type GetHealthResponse = HealthInfoSchema; +export type DeletePoolData = { + poolName: string; +}; + +export type DeletePoolResponse = void; + +export type GetPoolData = { + poolName: string; +}; + +export type GetPoolResponse = PoolResponse; + +export type GetProvidersData = { + limit?: number; + offset?: number; +}; + +export type GetProvidersResponse = ProviderCollectionResponse; + export type DeleteVariableData = { variableKey: string; }; @@ -922,6 +941,77 @@ export type $OpenApiTs = { }; }; }; + "/public/pools/{pool_name}": { + delete: { + req: DeletePoolData; + res: { + /** + * Successful Response + */ + 204: void; + /** + * Bad Request + */ + 400: HTTPExceptionResponse; + /** + * Unauthorized + */ + 401: HTTPExceptionResponse; + /** + * Forbidden + */ + 403: HTTPExceptionResponse; + /** + * Not Found + */ + 404: HTTPExceptionResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + get: { + req: GetPoolData; + res: { + /** + * Successful Response + */ + 200: PoolResponse; + /** + * Unauthorized + */ + 401: HTTPExceptionResponse; + /** + * Forbidden + */ + 403: HTTPExceptionResponse; + /** + * Not Found + */ + 404: HTTPExceptionResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + }; + "/public/providers/": { + get: { + req: GetProvidersData; + res: { + /** + * Successful Response + */ + 200: ProviderCollectionResponse; + /** + * Validation Error + */ + 422: HTTPValidationError; + }; + }; + }; "/public/variables/{variable_key}": { delete: { req: DeleteVariableData;