import {z} from 'zod' export type JumpcloudAppleMdmADESettingPatchMask = {fields?: Array | undefined}; export type JumpcloudAppleMdmSetupAssistantOption = 'UNKNOWN' | 'ACCESSIBILITY_SETUP' | 'ANALYTICS' | 'APPEARANCE_SETUP' | 'APPLE_ID_SIGN_IN' | 'APPLE_PAY_SETUP' | 'BACKUP_RESTORE' | 'DISPLAY_TONE' | 'FILEVAULT' | 'ICLOUD_ANALYTICS' | 'ICLOUD_DOCUMENTS_DESKTOP_SETUP' | 'LOCATION_SERVICES_SETUP' | 'PRIVACY_PANE' | 'SCREEN_TIME' | 'SIRI_SETUP' | 'TERMS_AND_CONDITIONS' | 'TOUCH_ID_SETUP' | 'APP_STORE' | 'DISPLAY_ZOOM' | 'DEVICE_TO_DEVICE_MIGRATION' | 'HOME_BUTTON' | 'IMESSAGE_AND_FACETIME' | 'MESSAGING_ACTIVATION_USING_PHONE_NUMBER' | 'MOVE_FROM_ANDROID' | 'PASSCODE' | 'RESTORE_COMPLETE' | 'SET_UP_CELLULAR' | 'SOFTWARE_UPDATE' | 'UPDATE_COMPLETE' | 'UNLOCK_WITH_WATCH' | 'WATCH_MIGRATION' | 'WELCOME' | 'ACTION_BUTTON' | 'ENABLE_LOCKDOWN_MODE' | 'INTELLIGENCE' | 'SAFETY' | 'TERMS_OF_ADDRESS' | 'WALLPAPER' | 'CAMERA_BUTTON' | 'ADDITIONAL_PRIVACY_SETTINGS' | 'MULTITASKING' | 'OS_SHOWCASE' | 'WEB_CONTENT_FILTERING' | 'SAFETY_AND_HANDLING' | 'LIQUID_GLASS'; export type JumpcloudAppleMdmWelcomeScreen = {button?: string | undefined, paragraph?: string | undefined, title?: string | undefined}; export type PatchApiApiV2ApplemdmsAdeTokensAdeTokenObjectIdAdeSettingsOsFamilyArgs = {adeTokenObjectId: string, osFamily: 'UNKNOWN' | 'DARWIN' | 'IOS', body: {defaultDeviceGroupObjectIds?: Array | undefined, enableZeroTouchEnrollment?: boolean | undefined, patchMask?: JumpcloudAppleMdmADESettingPatchMask | undefined, setupOptions?: Array | undefined, welcomeScreen?: JumpcloudAppleMdmWelcomeScreen | undefined}}; export type PatchApiApiV2ApplemdmsAdeTokensAdeTokenObjectIdAdeSettingsOsFamilyOptions = {baseUrl?: string | undefined, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiApiV2ApplemdmsAdeTokensAdeTokenObjectIdAdeSettingsOsFamilyResponse = z.unknown(); 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 ADE Settings * * PATCH /api/v2/applemdms/ade_tokens/{adeTokenObjectId}/ade_settings/{osFamily} */ export const patchApiApiV2ApplemdmsAdeTokensAdeTokenObjectIdAdeSettingsOsFamily = async (args: PatchApiApiV2ApplemdmsAdeTokensAdeTokenObjectIdAdeSettingsOsFamilyArgs, options?: PatchApiApiV2ApplemdmsAdeTokensAdeTokenObjectIdAdeSettingsOsFamilyOptions) => { const {baseUrl = "https://console.jumpcloud.com", fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/applemdms/ade_tokens/${encodeURIComponent(String(args.adeTokenObjectId))}/ade_settings/${encodeURIComponent(String(args.osFamily))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(patchApiApiV2ApplemdmsAdeTokensAdeTokenObjectIdAdeSettingsOsFamilyResponse, await res.json()) };