import {z} from 'zod' export type GoogleCloudAiplatformV1EncryptionSpec = {kmsKeyName?: string | undefined}; export type GoogleRpcStatus = {code?: number | undefined, details?: Array<{[key: string]: unknown}> | undefined, message?: string | undefined}; export type GoogleCloudAiplatformV1DnsPeeringConfig = {domain?: string | undefined, targetNetwork?: string | undefined, targetProject?: string | undefined}; export type GoogleCloudAiplatformV1PscInterfaceConfig = {dnsPeeringConfigs?: Array | undefined, networkAttachment?: string | undefined}; export type GoogleCloudAiplatformV1ResourcePoolAutoscalingSpec = {maxReplicaCount?: unknown | undefined, minReplicaCount?: unknown | undefined}; export type GoogleCloudAiplatformV1DiskSpec = {bootDiskSizeGb?: number | undefined, bootDiskType?: string | undefined}; export type GoogleCloudAiplatformV1ReservationAffinity = {key?: string | undefined, reservationAffinityType?: ('TYPE_UNSPECIFIED' | 'NO_RESERVATION' | 'ANY_RESERVATION' | 'SPECIFIC_RESERVATION') | undefined, values?: Array | undefined}; export type GoogleCloudAiplatformV1MachineSpec = {acceleratorCount?: number | undefined, acceleratorType?: ('ACCELERATOR_TYPE_UNSPECIFIED' | 'NVIDIA_TESLA_K80' | 'NVIDIA_TESLA_P100' | 'NVIDIA_TESLA_V100' | 'NVIDIA_TESLA_P4' | 'NVIDIA_TESLA_T4' | 'NVIDIA_TESLA_A100' | 'NVIDIA_A100_80GB' | 'NVIDIA_L4' | 'NVIDIA_H100_80GB' | 'NVIDIA_H100_MEGA_80GB' | 'NVIDIA_H200_141GB' | 'NVIDIA_B200' | 'NVIDIA_GB200' | 'NVIDIA_RTX_PRO_6000' | 'TPU_V2' | 'TPU_V3' | 'TPU_V4_POD' | 'TPU_V5_LITEPOD') | undefined, gpuPartitionSize?: string | undefined, machineType?: string | undefined, reservationAffinity?: GoogleCloudAiplatformV1ReservationAffinity | undefined, tpuTopology?: string | undefined}; export type GoogleCloudAiplatformV1ResourcePool = {autoscalingSpec?: GoogleCloudAiplatformV1ResourcePoolAutoscalingSpec | undefined, diskSpec?: GoogleCloudAiplatformV1DiskSpec | undefined, id?: string | undefined, machineSpec?: GoogleCloudAiplatformV1MachineSpec | undefined, replicaCount?: unknown | undefined, usedReplicaCount?: unknown | undefined}; export type GoogleCloudAiplatformV1ResourceRuntime = {accessUris?: {[key: string]: string} | undefined}; export type GoogleCloudAiplatformV1RayClusterAutoscalingSpec = {idleTimeoutMinutes?: unknown | undefined, upscalingSpeed?: unknown | undefined}; export type GoogleCloudAiplatformV1RayLogsSpec = {disabled?: boolean | undefined}; export type GoogleCloudAiplatformV1RayMetricSpec = {disabled?: boolean | undefined, enableUsageStatsCollection?: boolean | undefined}; export type GoogleCloudAiplatformV1RaySpec = {headNodeResourcePoolId?: string | undefined, imageUri?: string | undefined, rayClusterAutoscalingSpec?: GoogleCloudAiplatformV1RayClusterAutoscalingSpec | undefined, rayLogsSpec?: GoogleCloudAiplatformV1RayLogsSpec | undefined, rayMetricSpec?: GoogleCloudAiplatformV1RayMetricSpec | undefined, resourcePoolImages?: {[key: string]: string} | undefined}; export type GoogleCloudAiplatformV1ServiceAccountSpec = {enableCustomServiceAccount?: boolean | undefined, serviceAccount?: string | undefined}; export type GoogleCloudAiplatformV1ResourceRuntimeSpec = {raySpec?: GoogleCloudAiplatformV1RaySpec | undefined, serviceAccountSpec?: GoogleCloudAiplatformV1ServiceAccountSpec | undefined}; export type GoogleCloudAiplatformV1PersistentResource = {createTime?: unknown | undefined, displayName?: string | undefined, encryptionSpec?: GoogleCloudAiplatformV1EncryptionSpec | undefined, error?: GoogleRpcStatus | undefined, labels?: {[key: string]: string} | undefined, name?: string | undefined, network?: string | undefined, pscInterfaceConfig?: GoogleCloudAiplatformV1PscInterfaceConfig | undefined, reservedIpRanges?: Array | undefined, resourcePools?: Array | undefined, resourceRuntime?: GoogleCloudAiplatformV1ResourceRuntime | undefined, resourceRuntimeSpec?: GoogleCloudAiplatformV1ResourceRuntimeSpec | undefined, satisfiesPzi?: boolean | undefined, satisfiesPzs?: boolean | undefined, startTime?: unknown | undefined, state?: ('STATE_UNSPECIFIED' | 'PROVISIONING' | 'RUNNING' | 'STOPPING' | 'ERROR' | 'REBOOTING' | 'UPDATING') | undefined, updateTime?: unknown | undefined}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdPersistentResourcesPersistentResourcesIdArgs = {projectsId: string, locationsId: string, persistentResourcesId: string, updateMask?: unknown | undefined, body: GoogleCloudAiplatformV1PersistentResource}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdPersistentResourcesPersistentResourcesIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleRpcStatus = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const googleLongrunningOperation = z.object({done: z.boolean().optional(), error: googleRpcStatus.optional(), metadata: z.record(z.string(), z.unknown()).optional(), name: z.string().optional(), response: z.record(z.string(), z.unknown()).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 }; /** * Updates a PersistentResource. * * PATCH /v1/projects/{projectsId}/locations/{locationsId}/persistentResources/{persistentResourcesId} */ export const patchApiV1ProjectsProjectsIdLocationsLocationsIdPersistentResourcesPersistentResourcesId = async (args: PatchApiV1ProjectsProjectsIdLocationsLocationsIdPersistentResourcesPersistentResourcesIdArgs, options?: PatchApiV1ProjectsProjectsIdLocationsLocationsIdPersistentResourcesPersistentResourcesIdOptions) => { const {baseUrl = "https://aiplatform.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.updateMask != null) query.append("updateMask", String(args.updateMask)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/projects/${encodeURIComponent(String(args.projectsId))}/locations/${encodeURIComponent(String(args.locationsId))}/persistentResources/${encodeURIComponent(String(args.persistentResourcesId))}${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 validateResponse(googleLongrunningOperation, await res.json()) };