import {z} from 'zod' export type GetApiAccountsAccountIdentifierInfraprovidersInfraproviderIdentifierGatewaysArgs = {accountIdentifier: string, infraprovider_identifier: string, is_latest?: string | undefined}; export type GetApiAccountsAccountIdentifierInfraprovidersInfraproviderIdentifierGatewaysOptions = {baseUrl: string, bearerAuth?: string | undefined, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const typesCDEGateway = z.object({created: z.number().int().optional(), envoy_health: z.string().optional(), group_name: z.string().optional(), health: z.string().optional(), infra_provider_config_id: z.number().int().optional(), infra_provider_config_identifier: z.string().optional(), name: z.string().optional(), overall_health: z.string().optional(), region: z.string().optional(), space_id: z.number().int().optional(), space_path: z.string().optional(), updated: z.number().int().optional(), version: z.string().optional(), zone: z.string().optional()}); export const getApiAccountsAccountIdentifierInfraprovidersInfraproviderIdentifierGatewaysResponse = z.array(typesCDEGateway); 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 gateways * * GET /accounts/{accountIdentifier}/infraproviders/{infraprovider_identifier}/gateways */ export const getApiAccountsAccountIdentifierInfraprovidersInfraproviderIdentifierGateways = async (args: GetApiAccountsAccountIdentifierInfraprovidersInfraproviderIdentifierGatewaysArgs, options: GetApiAccountsAccountIdentifierInfraprovidersInfraproviderIdentifierGatewaysOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.is_latest != null) query.append("is_latest", String(args.is_latest)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/accounts/${encodeURIComponent(String(args.accountIdentifier))}/infraproviders/${encodeURIComponent(String(args.infraprovider_identifier))}/gateways${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(getApiAccountsAccountIdentifierInfraprovidersInfraproviderIdentifierGatewaysResponse, await res.json()) };