import {z} from 'zod' export type GetApiV1ParentH2oEngineProfilesListAssignedArgs = {parent: string, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ParentH2oEngineProfilesListAssignedOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const v1ProfileConstraintNumeric = z.object({min: z.string().optional(), max: z.string().nullable().optional(), default: z.string().optional(), cumulativeMax: z.string().nullable().optional()}); export const v1ProfileConstraintDuration = z.object({min: z.string().optional(), max: z.string().nullable().optional(), default: z.string().optional()}); export const v1H2OEngineProfile = z.object({name: z.string().optional(), displayName: z.string().optional(), priority: z.number().int().optional(), enabled: z.boolean().optional(), assignedOidcRolesEnabled: z.boolean().optional(), assignedOidcRoles: z.array(z.string()).optional(), maxRunningEngines: z.number().int().nullable().optional(), nodeCountConstraint: v1ProfileConstraintNumeric.optional(), cpuConstraint: v1ProfileConstraintNumeric.optional(), gpuConstraint: v1ProfileConstraintNumeric.optional(), memoryBytesConstraint: v1ProfileConstraintNumeric.optional(), maxIdleDurationConstraint: v1ProfileConstraintDuration.optional(), maxRunningDurationConstraint: v1ProfileConstraintDuration.optional(), yamlPodTemplateSpec: z.string().optional(), yamlGpuTolerations: z.string().optional(), createTime: z.string().optional(), updateTime: z.string().nullable().optional(), creator: z.string().optional(), updater: z.string().optional(), creatorDisplayName: z.string().optional(), updaterDisplayName: z.string().optional(), gpuResourceName: z.string().optional(), javaClasspath: z.string().optional(), javaOptions: z.string().optional(), h2oOptions: z.string().optional()}); export const v1ListAssignedH2OEngineProfilesResponse = z.object({h2oEngineProfiles: z.array(v1H2OEngineProfile).optional(), nextPageToken: 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 }; /** * Returns assigned H2OEngineProfiles that match OIDC roles of the caller. * (-- api-linter: core::0136::http-uri-suffix=disabled * aip.dev/not-precedent: Not a standard List method. --) * * GET /v1/{parent}/h2oEngineProfiles:listAssigned */ export const getApiV1ParentH2oEngineProfilesListAssigned = async (args: GetApiV1ParentH2oEngineProfilesListAssignedArgs, options: GetApiV1ParentH2oEngineProfilesListAssignedOptions) => { const {baseUrl, fetch: fetchFn = fetch} = 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)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/${encodeURIComponent(String(args.parent))}/h2oEngineProfiles:listAssigned${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(v1ListAssignedH2OEngineProfilesResponse, await res.json()) };