import {z} from 'zod' export type UpdateApiV1ConfigurationAccountidExceptionsHttpsObjectidArgs = {objectid: string, body: {id: string, object: string, version: number, account: string, created: number, device: 'firewan', author: string, description?: string | undefined, rule: string, type: 'fqdn' | 'ipv4_host' | 'ipv4_network', action?: 'allow' | undefined}}; export type UpdateApiV1ConfigurationAccountidExceptionsHttpsObjectidOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiV1ConfigurationAccountidExceptionsHttpsObjectidResponse = z.object({id: z.string(), object: z.string(), version: z.number().int(), account: z.string(), created: z.number().int(), device: z.literal("firewan"), author: z.string(), description: z.string().max(127).optional(), rule: z.string(), type: z.enum(["fqdn", "ipv4_host", "ipv4_network"]), action: z.literal("allow").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 }; /** * Updates the specified HTTPS decryption exception. * * PUT /v1/configuration/{accountid}/exceptions/https/{objectid} */ export const updateApiV1ConfigurationAccountidExceptionsHttpsObjectid = async (args: UpdateApiV1ConfigurationAccountidExceptionsHttpsObjectidArgs, options?: UpdateApiV1ConfigurationAccountidExceptionsHttpsObjectidOptions) => { const {baseUrl = "https://api.usa.cloud.watchguard.com/rest/firecloud/management", fetch: fetchFn = fetch, ApiKeyAuth, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("WatchGuard-API-Key", ApiKeyAuth) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/configuration/${encodeURIComponent(String(args.accountid))}/exceptions/https/${encodeURIComponent(String(args.objectid))}${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(updateApiV1ConfigurationAccountidExceptionsHttpsObjectidResponse, await res.json()) };