import { delete_ } from '../../../../lib/request/request-params-builder.ts'; import { safeUrl, sortBy } from '../../../../lib/utils.ts'; import { CcApiSimpleCommand } from '../../lib/cc-api-command.ts'; import type { IdResolve } from '../../types/resource-id-resolver.types.ts'; import type { DeleteEnvironmentVariableCommandInput, DeleteEnvironmentVariableCommandOutput, } from './delete-environment-variable-command.types.ts'; /** * Removes one environment variable from an application. * * The change only reaches the running instances on the next deployment. * * @endpoint [DELETE] /v2/organisations/:XXX/applications/:XXX/env/:XXX * @group Environment * @version 2 */ export class DeleteEnvironmentVariableCommand extends CcApiSimpleCommand< DeleteEnvironmentVariableCommandInput, DeleteEnvironmentVariableCommandOutput > { toRequestParams(params: DeleteEnvironmentVariableCommandInput) { return delete_( safeUrl`/v2/organisations/${params.ownerId}/applications/${params.applicationId}/env/${params.name}`, ); } transformCommandOutput(response: unknown): DeleteEnvironmentVariableCommandOutput { return sortBy((response as { env: DeleteEnvironmentVariableCommandOutput }).env, 'name'); } getIdsToResolve(): IdResolve { return { ownerId: true, }; } isIdempotent(): boolean { return true; } }