import {z} from 'zod' export type GoogleCloudApihubV1AllowedValue = {description?: string | undefined, displayName?: string | undefined, id?: string | undefined, immutable?: boolean | undefined}; export type GoogleCloudApihubV1EnumAttributeValues = {values?: Array | undefined}; export type GoogleCloudApihubV1StringAttributeValues = {values?: Array | undefined}; export type GoogleCloudApihubV1AttributeValues = {attribute?: string | undefined, enumValues?: GoogleCloudApihubV1EnumAttributeValues | undefined, jsonValues?: GoogleCloudApihubV1StringAttributeValues | undefined, stringValues?: GoogleCloudApihubV1StringAttributeValues | undefined, uriValues?: GoogleCloudApihubV1StringAttributeValues | undefined}; export type GoogleCloudApihubV1Documentation = {externalUri?: string | undefined}; export type GoogleCloudApihubV1PluginInstanceActionSource = {actionId?: string | undefined, pluginInstance?: string | undefined}; export type GoogleCloudApihubV1SourceMetadata = {originalResourceCreateTime?: unknown | undefined, originalResourceId?: string | undefined, originalResourceUpdateTime?: unknown | undefined, pluginInstanceActionSource?: GoogleCloudApihubV1PluginInstanceActionSource | undefined, sourceType?: ('SOURCE_TYPE_UNSPECIFIED' | 'PLUGIN') | undefined}; export type GoogleCloudApihubV1Deployment = {apiOperations?: Array | undefined, apiVersions?: Array | undefined, attributes?: {[key: string]: GoogleCloudApihubV1AttributeValues} | undefined, createTime?: unknown | undefined, deploymentType?: GoogleCloudApihubV1AttributeValues | undefined, description?: string | undefined, displayName?: string | undefined, documentation?: GoogleCloudApihubV1Documentation | undefined, endpoints?: Array | undefined, environment?: GoogleCloudApihubV1AttributeValues | undefined, managementUrl?: GoogleCloudApihubV1AttributeValues | undefined, name?: string | undefined, resourceUri?: string | undefined, slo?: GoogleCloudApihubV1AttributeValues | undefined, sourceEnvironment?: string | undefined, sourceMetadata?: Array | undefined, sourceProject?: string | undefined, sourceRevision?: string | undefined, sourceUri?: GoogleCloudApihubV1AttributeValues | undefined, specs?: Array | undefined, updateTime?: unknown | undefined}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdArgs = {projectsId: string, locationsId: string, deploymentsId: string, updateMask?: unknown | undefined, body: GoogleCloudApihubV1Deployment}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdOptions = {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 }; /** * Update a deployment resource in the API hub. The following fields in the deployment resource can be updated: * display_name * description * documentation * deployment_type * resource_uri * endpoints * slo * environment * attributes * source_project * source_environment * management_url * source_uri The update_mask should be used to specify the fields being updated. * * PATCH /v1/projects/{projectsId}/locations/{locationsId}/deployments/{deploymentsId} * * Also accepts auth: Oauth2 + Oauth2c */ export const patchApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsId = async (args: PatchApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdArgs, options?: PatchApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentsDeploymentsIdOptions) => { const {baseUrl = "https://apihub.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.updateMask != null) query.append("updateMask", String(args.updateMask)) 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: "PATCH", headers, body: JSON.stringify(args.body)}) 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()) };