import {z} from 'zod' export type GoogleCloudAiplatformV1EncryptionSpec = {kmsKeyName?: string | undefined}; export type GoogleCloudAiplatformV1ServingProfileCmekConfig = {encryptionSpec?: GoogleCloudAiplatformV1EncryptionSpec | undefined}; export type GoogleCloudAiplatformV1ServingProfile = {cmekConfig?: GoogleCloudAiplatformV1ServingProfileCmekConfig | undefined, createTime?: unknown | undefined, description?: string | undefined, displayName?: string | undefined, name?: string | undefined, scope?: ('SERVING_PROFILE_SCOPE_UNSPECIFIED' | 'GEMINI_LIVE' | 'INTERACTIONS_API' | 'RESPONSE_API') | undefined, updateTime?: unknown | undefined}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesServingProfilesIdArgs = {projectsId: string, locationsId: string, servingProfilesId: string, updateMask?: unknown | undefined, body: GoogleCloudAiplatformV1ServingProfile}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesServingProfilesIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudAiplatformV1EncryptionSpec = z.object({kmsKeyName: z.string().optional()}); export const googleCloudAiplatformV1ServingProfileCmekConfig = z.object({encryptionSpec: googleCloudAiplatformV1EncryptionSpec.optional()}); export const googleCloudAiplatformV1ServingProfile = z.object({cmekConfig: googleCloudAiplatformV1ServingProfileCmekConfig.optional(), createTime: z.string().optional(), description: z.string().optional(), displayName: z.string().optional(), name: z.string().optional(), scope: z.enum(["SERVING_PROFILE_SCOPE_UNSPECIFIED", "GEMINI_LIVE", "INTERACTIONS_API", "RESPONSE_API"]).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 ServingProfile. * * PATCH /v1/projects/{projectsId}/locations/{locationsId}/servingProfiles/{servingProfilesId} */ export const patchApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesServingProfilesId = async (args: PatchApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesServingProfilesIdArgs, options?: PatchApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesServingProfilesIdOptions) => { 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))}/servingProfiles/${encodeURIComponent(String(args.servingProfilesId))}${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(googleCloudAiplatformV1ServingProfile, await res.json()) };