import {z} from 'zod' export type GetApiV1AccountsAccountIdPricingPlansArgs = {pageSize?: number | undefined, pageToken?: string | undefined, filter?: string | undefined, orderBy?: string | undefined, readMask?: string | undefined, account_id: string}; export type GetApiV1AccountsAccountIdPricingPlansOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const pricingPlanBillingType = z.enum(["BILLING_TYPE_UNSPECIFIED", "TOKEN_USAGE", "ACCELERATOR_HOURS"]); export const typeMoney = z.object({currencyCode: z.string().optional(), units: z.string().optional(), nanos: z.number().int().optional()}); export const pricingPlanTokenBillingConfig = z.object({baseModelName: z.string(), inputTokenPricePerMillion: typeMoney.optional(), outputTokenPricePerMillion: typeMoney, uncachedInputTokenPricePerMillion: typeMoney.optional(), cachedInputTokenPricePerMillion: typeMoney.optional()}); export const gatewayAcceleratorType = z.enum(["ACCELERATOR_TYPE_UNSPECIFIED", "NVIDIA_A100_80GB", "NVIDIA_H100_80GB", "AMD_MI300X_192GB", "NVIDIA_A10G_24GB", "NVIDIA_A100_40GB", "NVIDIA_L4_24GB", "NVIDIA_H200_141GB", "NVIDIA_B200_180GB", "AMD_MI325X_256GB", "AMD_MI350X_288GB", "NVIDIA_B300_288GB", "NVIDIA_GB200", "NVIDIA_GB300"]); export const pricingPlanAcceleratorHourBillingConfig = z.object({acceleratorType: gatewayAcceleratorType, acceleratorHourPrice: typeMoney}); export const gatewayPricingPlanState = z.enum(["STATE_UNSPECIFIED", "CREATING", "READY"]); export const gatewayPricingPlan = z.object({name: z.string().optional(), billingType: pricingPlanBillingType, tokenConfig: z.array(pricingPlanTokenBillingConfig).optional(), acceleratorHourConfig: z.array(pricingPlanAcceleratorHourBillingConfig).optional(), startTime: z.string(), endTime: z.string().optional(), createTime: z.string().optional(), updateTime: z.string().optional(), state: gatewayPricingPlanState.optional()}); export const gatewayListPricingPlansResponse = z.object({pricingPlans: z.array(gatewayPricingPlan).optional(), nextPageToken: z.string().optional(), totalSize: z.number().int().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 }; /** * List Pricing Plans * * GET /v1/accounts/{account_id}/pricingPlans */ export const getApiV1AccountsAccountIdPricingPlans = async (args: GetApiV1AccountsAccountIdPricingPlansArgs, options: GetApiV1AccountsAccountIdPricingPlansOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = 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 (args.filter != null) query.append("filter", String(args.filter)) if (args.orderBy != null) query.append("orderBy", String(args.orderBy)) if (args.readMask != null) query.append("readMask", String(args.readMask)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/accounts/${encodeURIComponent(String(args.account_id))}/pricingPlans${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(gatewayListPricingPlansResponse, await res.json()) };