import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesArgs = {projectsId: string, locationsId: string, filter?: string | undefined, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesOptions = {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 googleCloudApihubV1Attribute = z.object({allowedValues: z.array(googleCloudApihubV1AllowedValue).optional(), cardinality: z.number().int().optional(), createTime: z.string().optional(), dataType: z.enum(["DATA_TYPE_UNSPECIFIED", "ENUM", "JSON", "STRING", "URI"]).optional(), definitionType: z.enum(["DEFINITION_TYPE_UNSPECIFIED", "SYSTEM_DEFINED", "USER_DEFINED"]).optional(), description: z.string().optional(), displayName: z.string().optional(), mandatory: z.boolean().optional(), name: z.string().optional(), scope: z.enum(["SCOPE_UNSPECIFIED", "API", "VERSION", "SPEC", "API_OPERATION", "DEPLOYMENT", "DEPENDENCY", "DEFINITION", "EXTERNAL_API", "PLUGIN"]).optional(), updateTime: z.string().optional()}); export const googleCloudApihubV1ListAttributesResponse = z.object({attributes: z.array(googleCloudApihubV1Attribute).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 all attributes. * * GET /v1/projects/{projectsId}/locations/{locationsId}/attributes * * Also accepts auth: Oauth2 + Oauth2c, Oauth2 + Oauth2c */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdAttributes = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesOptions) => { 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))}/attributes${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(googleCloudApihubV1ListAttributesResponse, await res.json()) };