import {z} from 'zod' export type UpdateApiRegistryV1CurrenttenantArgs = {body: {name?: string | undefined, id?: string | undefined, _id?: string | undefined, locale?: string | undefined, defaultContentLocale?: string | undefined, contentLocales?: Array | undefined, watsonConfidenceLevel?: number | undefined, maxUploadSize?: number | undefined, maxBulkUploadSize?: number | undefined, useSingleUploadSize?: boolean | undefined, maxUploadSizeDocument?: number | undefined, maxUploadSizeImage?: number | undefined, maxUploadSizeAudio?: number | undefined, maxUploadSizeVideo?: number | undefined, maxAuthors?: number | undefined, corsWhitelist?: Array | undefined, configDeliveryCacheMaxage?: number | undefined, mandatoryAssetPublishApproval?: ({enabled?: boolean | undefined, exemptAssetTypes?: Array | undefined}) | undefined, mandatoryContentPublishApproval?: ({enabled?: boolean | undefined, exemptContentTypes?: Array | undefined}) | undefined, ibmCommerce?: ({tenantId?: string | undefined, apiGatewayHost?: string | undefined, previewSearchHost?: string | undefined, previewTransactionHost?: string | undefined, liveSearchHost?: string | undefined, liveTransactionHost?: string | undefined, environmentType?: string | undefined}) | undefined, ibmWca?: Record | undefined, edgeToken?: string | undefined, importZip?: Record | undefined}}; export type UpdateApiRegistryV1CurrenttenantOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const updateApiRegistryV1CurrenttenantResponse = z.object({name: z.string().optional(), id: z.string().optional(), _id: z.string(), locale: z.string().optional(), defaultContentLocale: z.string().optional(), contentLocales: z.array(z.string()).optional(), locked: z.boolean().optional(), watsonConfidenceLevel: z.number().optional(), maxUploadSize: z.number().int().optional(), useSingleUploadSize: z.boolean().optional(), maxUploadSizeFiles: z.number().int().optional(), maxUploadSizeImage: z.number().int().optional(), maxUploadSizeVideo: z.number().int().optional(), maxAuthors: z.number().int().optional(), maxContentItems: z.number().int().optional(), maxStorageSize: z.number().int().optional(), maxDataTransfer: z.number().int().optional(), isDAMEnabled: z.boolean().optional(), tier: z.string().optional(), ibmUniqueId: z.string().optional(), isEdgeSideEnabled: z.boolean().optional(), maxUserSessions: z.number().int().optional(), configDeliveryCacheMaxage: z.number().int().optional(), capability: z.string().optional(), corsWhitelist: z.array(z.string()).optional(), mandatoryAssetPublishApproval: z.object({enabled: z.boolean().optional(), exemptAssetTypes: z.array(z.string()).optional()}).optional(), mandatoryContentPublishApproval: z.object({enabled: z.boolean().optional(), exemptContentTypes: z.array(z.string()).optional()}).optional(), deliveryAccess: z.object({secureAlways: z.boolean().optional(), content: z.string().optional(), assets: z.string().optional()}).optional(), ibmCommerce: z.object({tenantId: z.string().optional(), apiGatewayHost: z.string().optional(), previewSearchHost: z.string().optional(), previewTransactionHost: z.string().optional(), liveSearchHost: z.string().optional(), liveTransactionHost: z.string().optional(), environmentType: z.string().optional()}).optional(), ibmWca: z.object({}).optional(), edgeToken: z.string().optional(), importZip: z.object({}).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 tenant * * PUT /registry/v1/currenttenant */ export const updateApiRegistryV1Currenttenant = async (args: UpdateApiRegistryV1CurrenttenantArgs, options: UpdateApiRegistryV1CurrenttenantOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/registry/v1/currenttenant${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(updateApiRegistryV1CurrenttenantResponse, await res.json()) };