import {z} from 'zod' export type CreateApiV1OrganizationsWorkspacesWorkspaceIdArchiveBetaTrueArgs = {workspace_id: string, 'anthropic-version'?: string | undefined}; export type CreateApiV1OrganizationsWorkspacesWorkspaceIdArchiveBetaTrueOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const betaAllowedInferenceGeo = z.enum(["global", "us"]); export const betaInferenceGeo = z.enum(["global", "us"]); export const betaWorkspaceGeo = z.literal("us"); export const betaDataResidency = z.object({allowed_inference_geos: z.union([z.array(betaAllowedInferenceGeo), z.literal("unrestricted")]), default_inference_geo: betaInferenceGeo, workspace_geo: betaWorkspaceGeo}); export const betaWorkspace = z.object({archived_at: z.string().nullable(), compartment_id: z.string(), created_at: z.string(), data_residency: betaDataResidency, display_color: z.string(), external_key_id: z.string().nullable(), id: z.string(), name: z.string(), tags: z.record(z.string(), z.string()), type: z.literal("workspace"), user_profile_id: z.string().nullable()}); 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 }; /** * Archive Workspace * * POST /v1/organizations/workspaces/{workspace_id}/archive?beta=true */ export const createApiV1OrganizationsWorkspacesWorkspaceIdArchiveBetaTrue = async (args: CreateApiV1OrganizationsWorkspacesWorkspaceIdArchiveBetaTrueArgs, options?: CreateApiV1OrganizationsWorkspacesWorkspaceIdArchiveBetaTrueOptions) => { const {baseUrl = "https://api.anthropic.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['anthropic-version'] != null) headers.set("anthropic-version", String(args['anthropic-version'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/organizations/workspaces/${encodeURIComponent(String(args.workspace_id))}/archive?beta=true${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(betaWorkspace, await res.json()) };