import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdPluginsPluginsIdInstancesArgs = {projectsId: string, locationsId: string, pluginsId: string, filter?: string | undefined, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdPluginsPluginsIdInstancesOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudApihubV1CustomCuration = z.object({curation: z.string().optional()}); export const googleCloudApihubV1CurationConfig = z.object({curationType: z.enum(["CURATION_TYPE_UNSPECIFIED", "DEFAULT_CURATION_FOR_API_METADATA", "CUSTOM_CURATION_FOR_API_METADATA"]).optional(), customCuration: googleCloudApihubV1CustomCuration.optional()}); export const googleCloudApihubV1LastExecution = z.object({endTime: z.string().optional(), errorMessage: z.string().optional(), result: z.enum(["RESULT_UNSPECIFIED", "SUCCEEDED", "FAILED"]).optional(), resultMetadata: z.string().optional(), startTime: z.string().optional()}); export const googleCloudApihubV1ExecutionStatus = z.object({currentExecutionState: z.enum(["CURRENT_EXECUTION_STATE_UNSPECIFIED", "RUNNING", "NOT_RUNNING"]).optional(), lastExecution: googleCloudApihubV1LastExecution.optional()}); export const googleCloudApihubV1ResourceConfig = z.object({actionType: z.enum(["ACTION_TYPE_UNSPECIFIED", "SYNC_METADATA", "SYNC_RUNTIME_DATA"]).optional(), pubsubTopic: z.string().optional()}); export const googleCloudApihubV1PluginInstanceAction = z.object({actionId: z.string().optional(), curationConfig: googleCloudApihubV1CurationConfig.optional(), hubInstanceAction: googleCloudApihubV1ExecutionStatus.optional(), resourceConfig: googleCloudApihubV1ResourceConfig.optional(), scheduleCronExpression: z.string().optional(), scheduleTimeZone: z.string().optional(), serviceAccount: z.string().optional(), state: z.enum(["STATE_UNSPECIFIED", "ENABLED", "DISABLED", "ENABLING", "DISABLING", "ERROR"]).optional()}); export const googleCloudApihubV1ConfigValueOption = z.object({description: z.string().optional(), displayName: z.string().optional(), id: z.string().optional()}); export const googleCloudApihubV1MultiIntValues = z.object({values: z.array(z.number().int()).optional()}); export const googleCloudApihubV1MultiSelectValues = z.object({values: z.array(googleCloudApihubV1ConfigValueOption).optional()}); export const googleCloudApihubV1MultiStringValues = z.object({values: z.array(z.string()).optional()}); export const googleCloudApihubV1Secret = z.object({secretVersion: z.string().optional()}); export const googleCloudApihubV1ConfigVariable = z.object({boolValue: z.boolean().optional(), enumValue: googleCloudApihubV1ConfigValueOption.optional(), intValue: z.string().optional(), key: z.string().optional(), multiIntValues: googleCloudApihubV1MultiIntValues.optional(), multiSelectValues: googleCloudApihubV1MultiSelectValues.optional(), multiStringValues: googleCloudApihubV1MultiStringValues.optional(), secretValue: googleCloudApihubV1Secret.optional(), stringValue: z.string().optional()}); export const googleCloudApihubV1ApiKeyConfig = z.object({apiKey: googleCloudApihubV1Secret.optional(), httpElementLocation: z.enum(["HTTP_ELEMENT_LOCATION_UNSPECIFIED", "QUERY", "HEADER", "PATH", "BODY", "COOKIE"]).optional(), name: z.string().optional()}); export const googleCloudApihubV1GoogleServiceAccountConfig = z.object({serviceAccount: z.string().optional()}); export const googleCloudApihubV1Oauth2ClientCredentialsConfig = z.object({clientId: z.string().optional(), clientSecret: googleCloudApihubV1Secret.optional()}); export const googleCloudApihubV1UserPasswordConfig = z.object({password: googleCloudApihubV1Secret.optional(), username: z.string().optional()}); export const googleCloudApihubV1AuthConfig = z.object({apiKeyConfig: googleCloudApihubV1ApiKeyConfig.optional(), authType: z.enum(["AUTH_TYPE_UNSPECIFIED", "NO_AUTH", "GOOGLE_SERVICE_ACCOUNT", "USER_PASSWORD", "API_KEY", "OAUTH2_CLIENT_CREDENTIALS"]).optional(), googleServiceAccountConfig: googleCloudApihubV1GoogleServiceAccountConfig.optional(), oauth2ClientCredentialsConfig: googleCloudApihubV1Oauth2ClientCredentialsConfig.optional(), userPasswordConfig: googleCloudApihubV1UserPasswordConfig.optional()}); export const googleCloudApihubV1SourceEnvironment = z.object({createTime: z.string().optional(), sourceEnvironment: z.string().optional(), sourceEnvironmentUri: z.string().optional(), updateTime: z.string().optional()}); export const googleCloudApihubV1PluginInstance = z.object({actions: z.array(googleCloudApihubV1PluginInstanceAction).optional(), additionalConfig: z.record(z.string(), googleCloudApihubV1ConfigVariable).optional(), authConfig: googleCloudApihubV1AuthConfig.optional(), createTime: z.string().optional(), displayName: z.string().optional(), errorMessage: z.string().optional(), name: z.string().optional(), sourceEnvironmentsConfig: z.record(z.string(), googleCloudApihubV1SourceEnvironment).optional(), sourceProjectId: z.string().optional(), state: z.enum(["STATE_UNSPECIFIED", "CREATING", "ACTIVE", "APPLYING_CONFIG", "ERROR", "FAILED", "DELETING"]).optional(), updateTime: z.string().optional()}); export const googleCloudApihubV1ListPluginInstancesResponse = z.object({nextPageToken: z.string().optional(), pluginInstances: z.array(googleCloudApihubV1PluginInstance).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 all the plugins in a given project and location. `-` can be used as wildcard value for {plugin_id} * * GET /v1/projects/{projectsId}/locations/{locationsId}/plugins/{pluginsId}/instances * * Also accepts auth: Oauth2 + Oauth2c, Oauth2 + Oauth2c */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdPluginsPluginsIdInstances = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdPluginsPluginsIdInstancesArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdPluginsPluginsIdInstancesOptions) => { 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))}/plugins/${encodeURIComponent(String(args.pluginsId))}/instances${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(googleCloudApihubV1ListPluginInstancesResponse, await res.json()) };