import {z} from 'zod' export type GetApiEnterpriseEnterpriseIdGroupGroupIdDownloadEventfeedArgs = {enterprise_id: string, group_id: string, limit?: number | undefined, offset?: number | undefined}; export type GetApiEnterpriseEnterpriseIdGroupGroupIdDownloadEventfeedOptions = {baseUrl?: string | undefined, esperCloudApiApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const esperCloudApiV0DeviceCommandEnum = z.enum(["ADD_TO_WHITELIST", "ADD_WIFI_AP", "CLEAR_APP_DATA", "CLEAR_APP_CACHE", "INSTALL", "LOCK", "REBOOT", "REMOVE_FROM_WHITELIST", "REMOVE_WIFI_AP", "SET_APP_PERMISSION", "SET_APP_STATE", "SET_BLUETOOTH_STATE", "SET_BRIGHTNESS_SCALE", "SET_DEVICE_LOCKDOWN_STATE", "SET_GPS_STATE", "SET_KIOSK_APP", "SET_NEW_POLICY", "SET_ROTATION_STATE", "SET_SCREEN_OFF_TIMEOUT", "SET_STREAM_VOLUME", "SET_TIMEZONE", "SET_WIFI_STATE", "UNINSTALL", "UPDATE_DEVICE_CONFIG", "UPDATE_HEARTBEAT", "UPDATE_LATEST_DPC", "UPDATE_WIFI_AP", "WIPE", "RESET_LOCKSCREEN_PASSWORD", "UPDATE_BLUEPRINT", "CAPTURE_SCREENSHOT", "NOTIFY_DEVICE", "SET_DEVICE_LANGUAGE", "SET_ETHERNET_SETTINGS", "SET_STATIC_IP", "BEEP_DEVICE", "SET_APP_NOTIFICATIONS", "USE_ONLY_SAVED_WIFI_AP", "CONVERGE", "SYNC_CONTENT"]); export const esperCloudApiV0CommandArgs = z.object({device_alias_name: z.string().optional(), custom_settings_config: z.object({}).optional(), app_version: z.string().optional(), package_name: z.string().optional(), policy_url: z.string().optional(), wifi_access_points: z.object({}).optional(), state: z.string().optional(), message: z.string().optional(), title: z.string().optional(), url: z.string().optional(), app_state: z.string().optional(), bluetooth_state: z.boolean().optional(), brightness_value: z.number().int().optional(), gps_state: z.number().int().optional(), rotate_state: z.number().int().optional(), screen_off_timeout: z.number().int().optional(), stream: z.number().int().optional(), volume_level: z.number().int().optional(), timezone_string: z.number().int().optional(), wifi_state: z.boolean().optional(), wifi_revert_timeout: z.number().int().optional(), locale: z.string().optional(), ethernet_auth_mode: z.enum(["NONE", "EAP_TLS"]).optional(), ethernet_ca_cert_alias: z.string().optional(), ethernet_client_cert_alias: z.string().optional(), ethernet_eap_identity: z.string().optional(), interface: z.string().optional(), dhcp_enabled: z.string().optional(), static_ip: z.string().optional(), primary_dns: z.string().optional(), subnet_mask: z.string().optional(), secondary_dns: z.string().optional(), gateway: z.string().optional(), duration: z.string().optional(), tag: z.string().optional(), video_quality: z.string().optional(), enable_debug_mode: z.boolean().optional(), converge_with_provision_option: z.boolean().optional(), auto_update_mode: z.enum(["autoUpdateDefault", "autoUpdateHighPriority", "autoUpdatePostponed"]).optional(), content_id: z.string().optional()}); export const esperCloudApiV0CommandScheduleEnum = z.enum(["IMMEDIATE", "WINDOW", "RECURRING"]); export const esperCloudApiV0CommandScheduleArgsTimeTypeEnum = z.enum(["console", "device"]); export const esperCloudApiV0CommandScheduleArgs = z.object({name: z.string().optional(), start_datetime: z.string().optional(), end_datetime: z.string().optional(), time_type: esperCloudApiV0CommandScheduleArgsTimeTypeEnum.optional(), window_start_time: z.string().optional(), window_end_time: z.string().optional(), days: z.array(z.string()).optional()}); export const esperCloudApiV0CommandRequestStatus = z.object({state: z.string().optional(), total: z.number().int().optional()}); export const esperCloudApiV0CommandRequest = z.object({id: z.string().optional(), enterprise: z.string().optional(), command_type: z.enum(["DEVICE", "GROUP", "DYNAMIC"]).optional(), devices: z.array(z.string()).optional(), groups: z.array(z.string()).optional(), command: esperCloudApiV0DeviceCommandEnum.optional(), command_args: esperCloudApiV0CommandArgs.optional(), schedule: esperCloudApiV0CommandScheduleEnum.optional(), schedule_args: esperCloudApiV0CommandScheduleArgs.optional(), issued_by: z.string().optional(), created_on: z.string().optional(), status: z.array(esperCloudApiV0CommandRequestStatus).optional()}); export const getApiEnterpriseEnterpriseIdGroupGroupIdDownloadEventfeedResponse = z.object({count: z.number().int(), next: z.string().nullable().optional(), previous: z.string().nullable().optional(), results: z.array(esperCloudApiV0CommandRequest)}); 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 }; /** * Download Event Feed for Group * * GET /enterprise/{enterprise_id}/group/{group_id}/download/eventfeed/ */ export const getApiEnterpriseEnterpriseIdGroupGroupIdDownloadEventfeed = async (args: GetApiEnterpriseEnterpriseIdGroupGroupIdDownloadEventfeedArgs, options?: GetApiEnterpriseEnterpriseIdGroupGroupIdDownloadEventfeedOptions) => { const {baseUrl = "https://develop-api.esper.cloud/api", fetch: fetchFn = fetch, esperCloudApiApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (esperCloudApiApiKey !== undefined) headers.set('authorization', `Bearer ${esperCloudApiApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/enterprise/${encodeURIComponent(String(args.enterprise_id))}/group/${encodeURIComponent(String(args.group_id))}/download/eventfeed/${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(getApiEnterpriseEnterpriseIdGroupGroupIdDownloadEventfeedResponse, await res.json()) };