import {z} from 'zod' export type GetApiV1alpha1ProjectsProjectsIdLocationsLocationsIdQueryContactCenterQuotaArgs = {projectsId: string, locationsId: string}; export type GetApiV1alpha1ProjectsProjectsIdLocationsLocationsIdQueryContactCenterQuotaOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const quota = z.object({contactCenterCountLimit: z.number().int().optional(), contactCenterCountSum: z.number().int().optional(), contactCenterInstanceSize: z.enum(["INSTANCE_SIZE_UNSPECIFIED", "STANDARD_SMALL", "STANDARD_MEDIUM", "STANDARD_LARGE", "STANDARD_XLARGE", "STANDARD_2XLARGE", "STANDARD_3XLARGE", "MULTIREGION_SMALL", "MULTIREGION_MEDIUM", "MULTIREGION_LARGE", "MULTIREGION_XLARGE", "MULTIREGION_2XLARGE", "MULTIREGION_3XLARGE", "DEV_SMALL", "SANDBOX_SMALL", "TRIAL_SMALL", "TIME_LIMITED_TRIAL_SMALL"]).optional()}); export const contactCenterQuota = z.object({contactCenterCountLimit: z.number().int().optional(), contactCenterCountSum: z.number().int().optional(), quotas: z.array(quota).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 }; /** * Queries the contact center quota, an aggregation over all the projects, that belongs to the billing account, which the input project belongs to. * * GET /v1alpha1/projects/{projectsId}/locations/{locationsId}:queryContactCenterQuota */ export const getApiV1alpha1ProjectsProjectsIdLocationsLocationsIdQueryContactCenterQuota = async (args: GetApiV1alpha1ProjectsProjectsIdLocationsLocationsIdQueryContactCenterQuotaArgs, options?: GetApiV1alpha1ProjectsProjectsIdLocationsLocationsIdQueryContactCenterQuotaOptions) => { const {baseUrl = "https://contactcenteraiplatform.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() 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(/\/+$/, '')}/v1alpha1/projects/${encodeURIComponent(String(args.projectsId))}/locations/${encodeURIComponent(String(args.locationsId))}:queryContactCenterQuota${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(contactCenterQuota, await res.json()) };