import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdArgs = {projectsId: string, locationsId: string, deploymentsId: string}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdOptions = {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 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 }; /** * Get details about a deployment and the API versions linked to it. * * GET /v1/projects/{projectsId}/locations/{locationsId}/deployments/{deploymentsId} * * Also accepts auth: Oauth2 + Oauth2c, Oauth2 + Oauth2c */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsId = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdOptions) => { 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 (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/${encodeURIComponent(String(args.deploymentsId))}${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(googleCloudApihubV1Deployment, await res.json()) };