import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesAttributesIdArgs = {projectsId: string, locationsId: string, attributesId: string}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesAttributesIdOptions = {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 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 the attribute. * * GET /v1/projects/{projectsId}/locations/{locationsId}/attributes/{attributesId} * * Also accepts auth: Oauth2 + Oauth2c, Oauth2 + Oauth2c */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdAttributesAttributesId = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesAttributesIdArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdAttributesAttributesIdOptions) => { 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))}/attributes/${encodeURIComponent(String(args.attributesId))}${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(googleCloudApihubV1Attribute, await res.json()) };