diff --git a/api-client/src/runs/getErrorRecoveryPolicy.ts b/api-client/src/runs/getErrorRecoveryPolicy.ts new file mode 100644 index 00000000000..776be61cc87 --- /dev/null +++ b/api-client/src/runs/getErrorRecoveryPolicy.ts @@ -0,0 +1,17 @@ +import { GET, request } from '../request' + +import type { HostConfig } from '../types' +import type { ResponsePromise } from '../request' +import type { ErrorRecoveryPolicyResponse } from './types' + +export function getErrorRecoveryPolicy( + config: HostConfig, + runId: string +): ResponsePromise { + return request( + GET, + `/get/${runId}/errorRecoveryPolicy`, + null, + config + ) +} diff --git a/api-client/src/runs/index.ts b/api-client/src/runs/index.ts index 183b8f7e4d4..fff1f303543 100644 --- a/api-client/src/runs/index.ts +++ b/api-client/src/runs/index.ts @@ -15,6 +15,7 @@ export * from './createLabwareOffset' export * from './createLabwareDefinition' export * from './constants' export * from './updateErrorRecoveryPolicy' +export * from './getErrorRecoveryPolicy' export * from './types' export type { CreateRunData } from './createRun' diff --git a/api-client/src/runs/types.ts b/api-client/src/runs/types.ts index bf8596b66d7..8a97089eec7 100644 --- a/api-client/src/runs/types.ts +++ b/api-client/src/runs/types.ts @@ -203,7 +203,7 @@ export interface UpdateErrorRecoveryPolicyRequest { data: ErrorRecoveryPolicy } -export type UpdateErrorRecoveryPolicyResponse = Record +export type ErrorRecoveryPolicyResponse = Record /** * Current Run State Data diff --git a/api-client/src/runs/updateErrorRecoveryPolicy.ts b/api-client/src/runs/updateErrorRecoveryPolicy.ts index 2efdd974775..023e30d4029 100644 --- a/api-client/src/runs/updateErrorRecoveryPolicy.ts +++ b/api-client/src/runs/updateErrorRecoveryPolicy.ts @@ -6,7 +6,7 @@ import type { ErrorRecoveryPolicy, IfMatchType, UpdateErrorRecoveryPolicyRequest, - UpdateErrorRecoveryPolicyResponse, + ErrorRecoveryPolicyResponse, } from './types' import type { RunCommandError, RunTimeCommand } from '@opentrons/shared-data' @@ -20,13 +20,15 @@ export function updateErrorRecoveryPolicy( config: HostConfig, runId: string, policyRules: RecoveryPolicyRulesParams -): ResponsePromise { +): ResponsePromise { const policy = buildErrorRecoveryPolicyBody(policyRules) - return request< - UpdateErrorRecoveryPolicyResponse, - UpdateErrorRecoveryPolicyRequest - >(PUT, `/runs/${runId}/errorRecoveryPolicy`, { data: policy }, config) + return request( + PUT, + `/runs/${runId}/errorRecoveryPolicy`, + { data: policy }, + config + ) } function buildErrorRecoveryPolicyBody( diff --git a/react-api-client/src/runs/useUpdateErrorRecoveryPolicy.ts b/react-api-client/src/runs/useUpdateErrorRecoveryPolicy.ts index 1fa379b1bc5..10ea2a2cd22 100644 --- a/react-api-client/src/runs/useUpdateErrorRecoveryPolicy.ts +++ b/react-api-client/src/runs/useUpdateErrorRecoveryPolicy.ts @@ -12,24 +12,24 @@ import type { import type { AxiosError } from 'axios' import type { RecoveryPolicyRulesParams, - UpdateErrorRecoveryPolicyResponse, + ErrorRecoveryPolicyResponse, HostConfig, } from '@opentrons/api-client' -export type UseUpdateErrorRecoveryPolicyResponse = UseMutationResult< - UpdateErrorRecoveryPolicyResponse, +export type UseErrorRecoveryPolicyResponse = UseMutationResult< + ErrorRecoveryPolicyResponse, AxiosError, RecoveryPolicyRulesParams > & { updateErrorRecoveryPolicy: UseMutateFunction< - UpdateErrorRecoveryPolicyResponse, + ErrorRecoveryPolicyResponse, AxiosError, RecoveryPolicyRulesParams > } export type UseUpdateErrorRecoveryPolicyOptions = UseMutationOptions< - UpdateErrorRecoveryPolicyResponse, + ErrorRecoveryPolicyResponse, AxiosError, RecoveryPolicyRulesParams > @@ -37,11 +37,11 @@ export type UseUpdateErrorRecoveryPolicyOptions = UseMutationOptions< export function useUpdateErrorRecoveryPolicy( runId: string, options: UseUpdateErrorRecoveryPolicyOptions = {} -): UseUpdateErrorRecoveryPolicyResponse { +): UseErrorRecoveryPolicyResponse { const host = useHost() const mutation = useMutation< - UpdateErrorRecoveryPolicyResponse, + ErrorRecoveryPolicyResponse, AxiosError, RecoveryPolicyRulesParams >(