import {z} from 'zod' export type DeleteApiV1alpha1InferenceCapacityclaimsIdArgs = {id: string}; export type DeleteApiV1alpha1InferenceCapacityclaimsIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const capacityClaimResources = z.object({instanceId: z.string(), instanceCount: z.number().int(), zones: z.array(z.string()), capacityType: z.enum(["CAPACITY_TYPE_SERVERLESS", "CAPACITY_TYPE_CUSTOMER"])}); export const capacityClaimSpec = z.object({id: z.string().optional(), name: z.string().optional(), resources: capacityClaimResources.optional(), organizationId: z.string().optional()}); export const condition = z.object({type: z.string().optional(), lastUpdateTime: z.string().optional(), reason: z.string().optional(), message: z.string().optional(), zone: z.string().optional(), status: z.enum(["True", "False", "Unknown"]).optional()}); export const capacityClaimStatus = z.object({createdAt: z.string().optional(), updatedAt: z.string().optional(), conditions: z.array(condition).optional(), allocatedInstances: z.number().int().optional(), pendingInstances: z.number().int().optional(), status: z.enum(["STATUS_CREATING", "STATUS_READY", "STATUS_UPDATING", "STATUS_DELETING", "STATUS_ERROR", "STATUS_FAILED"]).optional()}); export const capacityClaim = z.object({spec: capacityClaimSpec.optional(), status: capacityClaimStatus.optional()}); export const deleteCapacityClaimResponse = z.object({capacityClaim: capacityClaim.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Delete capacity claim * * DELETE /v1alpha1/inference/capacityclaims/{id} */ export const deleteApiV1alpha1InferenceCapacityclaimsId = async (args: DeleteApiV1alpha1InferenceCapacityclaimsIdArgs, options?: DeleteApiV1alpha1InferenceCapacityclaimsIdOptions) => { const {baseUrl = "https://api.coreweave.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1alpha1/inference/capacityclaims/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deleteCapacityClaimResponse, await res.json()) };