import {z} from 'zod' export type DeleteApiV1ConfigurationAccountidExceptionsIpsObjectidArgs = {objectid: string}; export type DeleteApiV1ConfigurationAccountidExceptionsIpsObjectidOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const deleteApiV1ConfigurationAccountidExceptionsIpsObjectidResponse = 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(), action: z.enum(["allow", "block"]), alarm: z.boolean().optional(), description: z.string().max(127).optional(), signature_id: z.string(), inactive: z.boolean()}); 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 }; /** * Deletes the specified IPS signature exception. * * DELETE /v1/configuration/{accountid}/exceptions/ips/{objectid} */ export const deleteApiV1ConfigurationAccountidExceptionsIpsObjectid = async (args: DeleteApiV1ConfigurationAccountidExceptionsIpsObjectidArgs, options?: DeleteApiV1ConfigurationAccountidExceptionsIpsObjectidOptions) => { 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('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/ips/${encodeURIComponent(String(args.objectid))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deleteApiV1ConfigurationAccountidExceptionsIpsObjectidResponse, await res.json()) };