import {z} from 'zod' export type GoogleCloudAiplatformV1PersistentDiskSpec = {diskSizeGb?: unknown | undefined, diskType?: string | undefined}; export type GoogleCloudAiplatformV1EncryptionSpec = {kmsKeyName?: string | undefined}; export type GoogleCloudAiplatformV1NotebookEucConfig = {bypassActasCheck?: boolean | undefined, eucDisabled?: boolean | undefined}; export type GoogleCloudAiplatformV1NotebookIdleShutdownConfig = {idleShutdownDisabled?: boolean | undefined, idleTimeout?: unknown | 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 GoogleCloudAiplatformV1NetworkSpec = {enableInternetAccess?: boolean | undefined, network?: string | undefined, subnetwork?: string | undefined}; export type GoogleCloudAiplatformV1NotebookReservationAffinity = {consumeReservationType?: ('RESERVATION_AFFINITY_TYPE_UNSPECIFIED' | 'RESERVATION_NONE' | 'RESERVATION_ANY' | 'RESERVATION_SPECIFIC') | undefined, key?: string | undefined, values?: Array | undefined}; export type GoogleCloudAiplatformV1ShieldedVmConfig = {enableSecureBoot?: boolean | undefined}; export type GoogleCloudAiplatformV1ColabImage = {description?: string | undefined, releaseName?: string | undefined}; export type GoogleCloudAiplatformV1EnvVar = {name?: string | undefined, value?: string | undefined}; export type GoogleCloudAiplatformV1PostStartupScriptConfig = {postStartupScript?: string | undefined, postStartupScriptBehavior?: ('POST_STARTUP_SCRIPT_BEHAVIOR_UNSPECIFIED' | 'RUN_ONCE' | 'RUN_EVERY_START' | 'DOWNLOAD_AND_RUN_EVERY_START') | undefined, postStartupScriptUrl?: string | undefined}; export type GoogleCloudAiplatformV1NotebookSoftwareConfig = {colabImage?: GoogleCloudAiplatformV1ColabImage | undefined, env?: Array | undefined, postStartupScriptConfig?: GoogleCloudAiplatformV1PostStartupScriptConfig | undefined}; export type GoogleCloudAiplatformV1NotebookRuntimeTemplate = {createTime?: unknown | undefined, dataPersistentDiskSpec?: GoogleCloudAiplatformV1PersistentDiskSpec | undefined, description?: string | undefined, displayName?: string | undefined, encryptionSpec?: GoogleCloudAiplatformV1EncryptionSpec | undefined, etag?: string | undefined, eucConfig?: GoogleCloudAiplatformV1NotebookEucConfig | undefined, idleShutdownConfig?: GoogleCloudAiplatformV1NotebookIdleShutdownConfig | undefined, isDefault?: boolean | undefined, labels?: {[key: string]: string} | undefined, machineSpec?: GoogleCloudAiplatformV1MachineSpec | undefined, name?: string | undefined, networkSpec?: GoogleCloudAiplatformV1NetworkSpec | undefined, networkTags?: Array | undefined, notebookRuntimeType?: ('NOTEBOOK_RUNTIME_TYPE_UNSPECIFIED' | 'USER_DEFINED' | 'ONE_CLICK') | undefined, reservationAffinity?: GoogleCloudAiplatformV1NotebookReservationAffinity | undefined, serviceAccount?: string | undefined, shieldedVmConfig?: GoogleCloudAiplatformV1ShieldedVmConfig | undefined, softwareConfig?: GoogleCloudAiplatformV1NotebookSoftwareConfig | undefined, updateTime?: unknown | undefined}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesNotebookRuntimeTemplatesIdArgs = {projectsId: string, locationsId: string, notebookRuntimeTemplatesId: string, updateMask?: unknown | undefined, body: GoogleCloudAiplatformV1NotebookRuntimeTemplate}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesNotebookRuntimeTemplatesIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudAiplatformV1PersistentDiskSpec = z.object({diskSizeGb: z.string().optional(), diskType: z.string().optional()}); export const googleCloudAiplatformV1EncryptionSpec = z.object({kmsKeyName: z.string().optional()}); export const googleCloudAiplatformV1NotebookEucConfig = z.object({bypassActasCheck: z.boolean().optional(), eucDisabled: z.boolean().optional()}); export const googleCloudAiplatformV1NotebookIdleShutdownConfig = z.object({idleShutdownDisabled: z.boolean().optional(), idleTimeout: z.string().optional()}); export const googleCloudAiplatformV1ReservationAffinity = z.object({key: z.string().optional(), reservationAffinityType: z.enum(["TYPE_UNSPECIFIED", "NO_RESERVATION", "ANY_RESERVATION", "SPECIFIC_RESERVATION"]).optional(), values: z.array(z.string()).optional()}); export const googleCloudAiplatformV1MachineSpec = z.object({acceleratorCount: z.number().int().optional(), acceleratorType: z.enum(["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"]).optional(), gpuPartitionSize: z.string().optional(), machineType: z.string().optional(), reservationAffinity: googleCloudAiplatformV1ReservationAffinity.optional(), tpuTopology: z.string().optional()}); export const googleCloudAiplatformV1NetworkSpec = z.object({enableInternetAccess: z.boolean().optional(), network: z.string().optional(), subnetwork: z.string().optional()}); export const googleCloudAiplatformV1NotebookReservationAffinity = z.object({consumeReservationType: z.enum(["RESERVATION_AFFINITY_TYPE_UNSPECIFIED", "RESERVATION_NONE", "RESERVATION_ANY", "RESERVATION_SPECIFIC"]).optional(), key: z.string().optional(), values: z.array(z.string()).optional()}); export const googleCloudAiplatformV1ShieldedVmConfig = z.object({enableSecureBoot: z.boolean().optional()}); export const googleCloudAiplatformV1ColabImage = z.object({description: z.string().optional(), releaseName: z.string().optional()}); export const googleCloudAiplatformV1EnvVar = z.object({name: z.string().optional(), value: z.string().optional()}); export const googleCloudAiplatformV1PostStartupScriptConfig = z.object({postStartupScript: z.string().optional(), postStartupScriptBehavior: z.enum(["POST_STARTUP_SCRIPT_BEHAVIOR_UNSPECIFIED", "RUN_ONCE", "RUN_EVERY_START", "DOWNLOAD_AND_RUN_EVERY_START"]).optional(), postStartupScriptUrl: z.string().optional()}); export const googleCloudAiplatformV1NotebookSoftwareConfig = z.object({colabImage: googleCloudAiplatformV1ColabImage.optional(), env: z.array(googleCloudAiplatformV1EnvVar).optional(), postStartupScriptConfig: googleCloudAiplatformV1PostStartupScriptConfig.optional()}); export const googleCloudAiplatformV1NotebookRuntimeTemplate = z.object({createTime: z.string().optional(), dataPersistentDiskSpec: googleCloudAiplatformV1PersistentDiskSpec.optional(), description: z.string().optional(), displayName: z.string().optional(), encryptionSpec: googleCloudAiplatformV1EncryptionSpec.optional(), etag: z.string().optional(), eucConfig: googleCloudAiplatformV1NotebookEucConfig.optional(), idleShutdownConfig: googleCloudAiplatformV1NotebookIdleShutdownConfig.optional(), isDefault: z.boolean().optional(), labels: z.record(z.string(), z.string()).optional(), machineSpec: googleCloudAiplatformV1MachineSpec.optional(), name: z.string().optional(), networkSpec: googleCloudAiplatformV1NetworkSpec.optional(), networkTags: z.array(z.string()).optional(), notebookRuntimeType: z.enum(["NOTEBOOK_RUNTIME_TYPE_UNSPECIFIED", "USER_DEFINED", "ONE_CLICK"]).optional(), reservationAffinity: googleCloudAiplatformV1NotebookReservationAffinity.optional(), serviceAccount: z.string().optional(), shieldedVmConfig: googleCloudAiplatformV1ShieldedVmConfig.optional(), softwareConfig: googleCloudAiplatformV1NotebookSoftwareConfig.optional(), updateTime: z.string().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 NotebookRuntimeTemplate. * * PATCH /v1/projects/{projectsId}/locations/{locationsId}/notebookRuntimeTemplates/{notebookRuntimeTemplatesId} */ export const patchApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesNotebookRuntimeTemplatesId = async (args: PatchApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesNotebookRuntimeTemplatesIdArgs, options?: PatchApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesNotebookRuntimeTemplatesIdOptions) => { 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))}/notebookRuntimeTemplates/${encodeURIComponent(String(args.notebookRuntimeTemplatesId))}${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(googleCloudAiplatformV1NotebookRuntimeTemplate, await res.json()) };