export type DORADeploymentPatchRemediationType = 'rollback' | 'rollforward'; export type DORADeploymentPatchByVersionRemediationByID = {id: string, type: DORADeploymentPatchRemediationType}; export type DORADeploymentPatchByVersionRemediationByVersion = {type: DORADeploymentPatchRemediationType, version: string}; export type DORADeploymentPatchByVersionRemediation = DORADeploymentPatchByVersionRemediationByID | DORADeploymentPatchByVersionRemediationByVersion; export type DORADeploymentPatchByVersionRequestAttributes = {change_failure: boolean, env: string, remediation?: DORADeploymentPatchByVersionRemediation | undefined, service: string, version: string}; export type DORADeploymentPatchRequestDataType = 'dora_deployment_patch_request'; export type DORADeploymentPatchByVersionRequestData = {attributes: DORADeploymentPatchByVersionRequestAttributes, type: DORADeploymentPatchRequestDataType}; export type DORADeploymentPatchByVersionRequest = {data: DORADeploymentPatchByVersionRequestData}; export type PatchApiApiV2DoraDeploymentsArgs = {body: DORADeploymentPatchByVersionRequest}; export type PatchApiApiV2DoraDeploymentsOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, appKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Mark a deployment as failed by version * * PATCH /api/v2/dora/deployments * * Also accepts auth: AuthZ */ export const patchApiApiV2DoraDeployments = async (args: PatchApiApiV2DoraDeploymentsArgs, options?: PatchApiApiV2DoraDeploymentsOptions) => { const {baseUrl = "https://api.datadoghq.com", fetch: fetchFn = fetch, apiKeyAuth, appKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKeyAuth !== undefined) headers.set("DD-API-KEY", apiKeyAuth) if (appKeyAuth !== undefined) headers.set("DD-APPLICATION-KEY", appKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/dora/deployments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };