import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsArgs = {projectsId: string, locationsId: string, filter?: string | undefined, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudApihubV1AllowedValue = z.object({description: z.string().optional(), displayName: z.string().optional(), id: z.string().optional(), immutable: z.boolean().optional()}); export const googleCloudApihubV1EnumAttributeValues = z.object({values: z.array(googleCloudApihubV1AllowedValue).optional()}); export const googleCloudApihubV1StringAttributeValues = z.object({values: z.array(z.string()).optional()}); export const googleCloudApihubV1AttributeValues = z.object({attribute: z.string().optional(), enumValues: googleCloudApihubV1EnumAttributeValues.optional(), jsonValues: googleCloudApihubV1StringAttributeValues.optional(), stringValues: googleCloudApihubV1StringAttributeValues.optional(), uriValues: googleCloudApihubV1StringAttributeValues.optional()}); export const googleCloudApihubV1Documentation = z.object({externalUri: z.string().optional()}); export const googleCloudApihubV1PluginInstanceActionSource = z.object({actionId: z.string().optional(), pluginInstance: z.string().optional()}); export const googleCloudApihubV1SourceMetadata = z.object({originalResourceCreateTime: z.string().optional(), originalResourceId: z.string().optional(), originalResourceUpdateTime: z.string().optional(), pluginInstanceActionSource: googleCloudApihubV1PluginInstanceActionSource.optional(), sourceType: z.enum(["SOURCE_TYPE_UNSPECIFIED", "PLUGIN"]).optional()}); export const googleCloudApihubV1Deployment = z.object({apiOperations: z.array(z.string()).optional(), apiVersions: z.array(z.string()).optional(), attributes: z.record(z.string(), googleCloudApihubV1AttributeValues).optional(), createTime: z.string().optional(), deploymentType: googleCloudApihubV1AttributeValues.optional(), description: z.string().optional(), displayName: z.string().optional(), documentation: googleCloudApihubV1Documentation.optional(), endpoints: z.array(z.string()).optional(), environment: googleCloudApihubV1AttributeValues.optional(), managementUrl: googleCloudApihubV1AttributeValues.optional(), name: z.string().optional(), resourceUri: z.string().optional(), slo: googleCloudApihubV1AttributeValues.optional(), sourceEnvironment: z.string().optional(), sourceMetadata: z.array(googleCloudApihubV1SourceMetadata).optional(), sourceProject: z.string().optional(), sourceRevision: z.string().optional(), sourceUri: googleCloudApihubV1AttributeValues.optional(), specs: z.array(z.string()).optional(), updateTime: z.string().optional()}); export const googleCloudApihubV1ListDeploymentsResponse = z.object({deployments: z.array(googleCloudApihubV1Deployment).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 deployment resources in the API hub. * * GET /v1/projects/{projectsId}/locations/{locationsId}/deployments * * Also accepts auth: Oauth2 + Oauth2c, Oauth2 + Oauth2c */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdDeployments = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsOptions) => { 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))}/deployments${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(googleCloudApihubV1ListDeploymentsResponse, await res.json()) };