import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdAddonsArgs = {projectsId: string, locationsId: string, filter?: string | undefined, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdAddonsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudApihubV1AllDataAddonConfig = z.object({enabled: z.boolean().optional()}); export const googleCloudApihubV1EnvironmentFilter = z.object({allEnvironments: z.boolean().optional(), environments: z.array(z.string()).optional()}); export const googleCloudApihubV1ApigeeEdgeConfig = z.object({environmentFilter: googleCloudApihubV1EnvironmentFilter.optional()}); export const googleCloudApihubV1ApigeeOPDKConfig = z.object({environmentFilter: googleCloudApihubV1EnvironmentFilter.optional()}); export const googleCloudApihubV1ApigeeXHybridConfig = z.object({environmentFilter: googleCloudApihubV1EnvironmentFilter.optional()}); export const googleCloudApihubV1GatewayPluginConfig = z.object({apigeeEdgeConfig: googleCloudApihubV1ApigeeEdgeConfig.optional(), apigeeOpdkConfig: googleCloudApihubV1ApigeeOPDKConfig.optional(), apigeeXHybridConfig: googleCloudApihubV1ApigeeXHybridConfig.optional(), pluginInstance: z.string().optional()}); export const googleCloudApihubV1GatewayPluginAddonConfig = z.object({gatewayPluginConfigs: z.array(googleCloudApihubV1GatewayPluginConfig).optional()}); export const googleCloudApihubV1AddonConfig = z.object({allDataAddonConfig: googleCloudApihubV1AllDataAddonConfig.optional(), gatewayPluginAddonConfig: googleCloudApihubV1GatewayPluginAddonConfig.optional()}); export const googleCloudApihubV1Addon = z.object({boostSpecGeminiRegionId: z.string().optional(), config: googleCloudApihubV1AddonConfig.optional(), createTime: z.string().optional(), dataSource: z.enum(["DATA_SOURCE_UNSPECIFIED", "PLUGIN_INSTANCE", "ALL_DATA"]).optional(), description: z.string().optional(), displayName: z.string().optional(), name: z.string().optional(), state: z.enum(["ADDON_STATE_UNSPECIFIED", "ACTIVE", "UPDATING", "ERROR", "INACTIVE"]).optional(), updateTime: z.string().optional()}); export const googleCloudApihubV1ListAddonsResponse = z.object({addons: z.array(googleCloudApihubV1Addon).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 }; /** * List addons. * * GET /v1/projects/{projectsId}/locations/{locationsId}/addons * * Also accepts auth: Oauth2 + Oauth2c, Oauth2 + Oauth2c */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdAddons = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdAddonsArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdAddonsOptions) => { const {baseUrl = "https://apihub.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.filter != null) query.append("filter", String(args.filter)) 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))}/addons${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(googleCloudApihubV1ListAddonsResponse, await res.json()) };