import {z} from 'zod' export type GetApiApiV1AccountsAccountIdDevicesprotectionstatusArgs = {accountId: string, top?: number | undefined, skip?: number | undefined, search?: string | undefined, count?: boolean | undefined, orderby?: string | undefined}; export type GetApiApiV1AccountsAccountIdDevicesprotectionstatusOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const protectionStatusResult = z.object({host_name: z.string().optional(), device_id: z.string().optional(), platform_id: z.union([z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5)]).optional(), device_type: z.union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)]).optional(), accumulated_protection_status: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6)]).optional(), adaptive_defense_status: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6)]).optional(), file_antivirus_status: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6)]).optional(), firewall_status: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6)]).optional(), isolation_state: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)]).optional(), protection_engine_update_status: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)]).optional(), protection_engine_version: z.string().optional(), knowledge_catalog_update_status: z.union([z.literal(0), z.literal(1), z.literal(2)]).optional(), knowledge_catalog_date: z.string().optional(), last_connection_date: z.string().optional(), reboot_requested: z.boolean().nullable().optional(), reinstall_protection_requested: z.boolean().nullable().optional(), reinstall_agent_requested: z.boolean().nullable().optional(), license_status: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)]).optional(), reinstall_agent_error: z.unknown(), reinstall_protection_error: z.unknown()}); export const protectionStatusResultFindResponse = z.object({data: protectionStatusResult.optional(), total_items: z.number().int().nullable().optional()}); export const getApiApiV1AccountsAccountIdDevicesprotectionstatusResponse = z.array(protectionStatusResultFindResponse); 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 }; /** * Retrieves device protection status. * * GET /api/v1/accounts/{accountId}/devicesprotectionstatus */ export const getApiApiV1AccountsAccountIdDevicesprotectionstatus = async (args: GetApiApiV1AccountsAccountIdDevicesprotectionstatusArgs, options?: GetApiApiV1AccountsAccountIdDevicesprotectionstatusOptions) => { const {baseUrl = "https://api.usa.cloud.watchguard.com/rest/aether-endpoint-security/aether-mgmt", fetch: fetchFn = fetch, ApiKeyAuth, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.top != null) query.append("top", String(args.top)) if (args.skip != null) query.append("skip", String(args.skip)) if (args.search != null) query.append("search", String(args.search)) if (args.count != null) query.append("count", String(args.count)) if (args.orderby != null) query.append("orderby", String(args.orderby)) if (ApiKeyAuth !== undefined) headers.set("WatchGuard-API-Key", ApiKeyAuth) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/accounts/${encodeURIComponent(String(args.accountId))}/devicesprotectionstatus${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(getApiApiV1AccountsAccountIdDevicesprotectionstatusResponse, await res.json()) };