Skip to content

Commit

Permalink
replace patch with put
Browse files Browse the repository at this point in the history
  • Loading branch information
rawwar committed Oct 19, 2024
1 parent 816dcb8 commit f1dad1c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 56 deletions.
2 changes: 1 addition & 1 deletion airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
patch:
put:
tags:
- DagRun
summary: Update Dag Run State
Expand Down
4 changes: 1 addition & 3 deletions airflow/api_fastapi/core_api/routes/public/dag_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def delete_dag_run(dag_id: str, dag_run_id: str, session: Annotated[Sessio
session.delete(dag_run)


@dag_run_router.patch("/{dag_run_id}", responses=create_openapi_http_exception_doc([400, 401, 403, 404]))
@dag_run_router.put("/{dag_run_id}", responses=create_openapi_http_exception_doc([400, 401, 403, 404]))
async def update_dag_run_state(
dag_id: str,
dag_run_id: str,
Expand All @@ -88,10 +88,8 @@ async def update_dag_run_state(
print("State is ", state)
print("stats equals", state == DAGRunModifyStates.SUCCESS)
if state.state == DAGRunModifyStates.SUCCESS:
print("Setting state to success")
set_dag_run_state_to_success(dag=dag, run_id=dag_run.run_id, commit=True)
elif state.state == DAGRunModifyStates.QUEUED:
print("setting state to queued")
set_dag_run_state_to_queued(dag=dag, run_id=dag_run.run_id, commit=True)
else:
set_dag_run_state_to_failed(dag=dag, run_id=dag_run.run_id, commit=True)
Expand Down
6 changes: 3 additions & 3 deletions airflow/ui/openapi-gen/queries/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ export const UseMonitorServiceGetHealthKeyFn = (queryKey?: Array<unknown>) => [
export type VariableServicePostVariableMutationResult = Awaited<
ReturnType<typeof VariableService.postVariable>
>;
export type DagRunServiceUpdateDagRunStateMutationResult = Awaited<
ReturnType<typeof DagRunService.updateDagRunState>
>;
export type DagServicePatchDagsMutationResult = Awaited<
ReturnType<typeof DagService.patchDags>
>;
Expand All @@ -257,9 +260,6 @@ export type DagServicePatchDagMutationResult = Awaited<
export type VariableServicePatchVariableMutationResult = Awaited<
ReturnType<typeof VariableService.patchVariable>
>;
export type DagRunServiceUpdateDagRunStateMutationResult = Awaited<
ReturnType<typeof DagRunService.updateDagRunState>
>;
export type DagServiceDeleteDagMutationResult = Awaited<
ReturnType<typeof DagService.deleteDag>
>;
Expand Down
94 changes: 47 additions & 47 deletions airflow/ui/openapi-gen/queries/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,53 @@ export const useVariableServicePostVariable = <
}) as unknown as Promise<TData>,
...options,
});
/**
* Update Dag Run State
* Modify a DAG Run.
* @param data The data for the request.
* @param data.dagId
* @param data.dagRunId
* @param data.requestBody
* @returns DAGRunResponse Successful Response
* @throws ApiError
*/
export const useDagRunServiceUpdateDagRunState = <
TData = Common.DagRunServiceUpdateDagRunStateMutationResult,
TError = unknown,
TContext = unknown,
>(
options?: Omit<
UseMutationOptions<
TData,
TError,
{
dagId: string;
dagRunId: string;
requestBody: DAGRunPatchBody;
},
TContext
>,
"mutationFn"
>,
) =>
useMutation<
TData,
TError,
{
dagId: string;
dagRunId: string;
requestBody: DAGRunPatchBody;
},
TContext
>({
mutationFn: ({ dagId, dagRunId, requestBody }) =>
DagRunService.updateDagRunState({
dagId,
dagRunId,
requestBody,
}) as unknown as Promise<TData>,
...options,
});
/**
* Patch Dags
* Patch multiple DAGs.
Expand Down Expand Up @@ -610,53 +657,6 @@ export const useVariableServicePatchVariable = <
}) as unknown as Promise<TData>,
...options,
});
/**
* Update Dag Run State
* Modify a DAG Run.
* @param data The data for the request.
* @param data.dagId
* @param data.dagRunId
* @param data.requestBody
* @returns DAGRunResponse Successful Response
* @throws ApiError
*/
export const useDagRunServiceUpdateDagRunState = <
TData = Common.DagRunServiceUpdateDagRunStateMutationResult,
TError = unknown,
TContext = unknown,
>(
options?: Omit<
UseMutationOptions<
TData,
TError,
{
dagId: string;
dagRunId: string;
requestBody: DAGRunPatchBody;
},
TContext
>,
"mutationFn"
>,
) =>
useMutation<
TData,
TError,
{
dagId: string;
dagRunId: string;
requestBody: DAGRunPatchBody;
},
TContext
>({
mutationFn: ({ dagId, dagRunId, requestBody }) =>
DagRunService.updateDagRunState({
dagId,
dagRunId,
requestBody,
}) as unknown as Promise<TData>,
...options,
});
/**
* Delete Dag
* Delete the specific DAG.
Expand Down
2 changes: 1 addition & 1 deletion airflow/ui/openapi-gen/requests/services.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ export class DagRunService {
data: UpdateDagRunStateData,
): CancelablePromise<UpdateDagRunStateResponse> {
return __request(OpenAPI, {
method: "PATCH",
method: "PUT",
url: "/public/dags/{dag_id}/dagRuns/{dag_run_id}",
path: {
dag_id: data.dagId,
Expand Down
2 changes: 1 addition & 1 deletion airflow/ui/openapi-gen/requests/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ export type $OpenApiTs = {
422: HTTPValidationError;
};
};
patch: {
put: {
req: UpdateDagRunStateData;
res: {
/**
Expand Down

0 comments on commit f1dad1c

Please sign in to comment.