import {z} from 'zod' export type GoogleCloudAiplatformV1SetDefaultNotebookRuntimeTemplateRequest = {name?: string | undefined}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesSetDefaultArgs = {projectsId: string, locationsId: string, body: GoogleCloudAiplatformV1SetDefaultNotebookRuntimeTemplateRequest}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesSetDefaultOptions = {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 googleCloudAiplatformV1SetDefaultNotebookRuntimeTemplateResponse = z.object({notebookRuntimeTemplate: googleCloudAiplatformV1NotebookRuntimeTemplate.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 }; /** * Sets the default NotebookRuntimeTemplate for a Location. * * POST /v1/projects/{projectsId}/locations/{locationsId}/notebookRuntimeTemplates:setDefault */ export const createApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesSetDefault = async (args: CreateApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesSetDefaultArgs, options?: CreateApiV1ProjectsProjectsIdLocationsLocationsIdNotebookRuntimeTemplatesSetDefaultOptions) => { 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 (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:setDefault${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(googleCloudAiplatformV1SetDefaultNotebookRuntimeTemplateResponse, await res.json()) };