import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesArgs = {projectsId: string, locationsId: string, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesOptions = {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 googleCloudAiplatformV1ListServingProfilesResponse = z.object({nextPageToken: z.string().optional(), servingProfiles: z.array(googleCloudAiplatformV1ServingProfile).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 }; /** * Lists ServingProfiles in a Location. * * GET /v1/projects/{projectsId}/locations/{locationsId}/servingProfiles */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdServingProfiles = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdServingProfilesOptions) => { const {baseUrl = "https://aiplatform.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) 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${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(googleCloudAiplatformV1ListServingProfilesResponse, await res.json()) };