import {z} from 'zod' export type RestrictedField = {field?: ('addresses' | 'company' | 'costCenter' | 'department' | 'description' | 'displayname' | 'email' | 'employeeIdentifier' | 'employeeType' | 'firstname' | 'jobTitle' | 'lastname' | 'location' | 'middlename' | 'password' | 'phoneNumbers' | 'sudo' | 'username') | undefined, type?: ('active_directory' | 'federated_identity_provider' | 'scim') | undefined, id?: string | undefined}; export type TrustedappConfigPut = {trustedApps: Array<{name: string, path?: string | undefined, teamid?: string | undefined}>}; export type Organizationsettingsput = {contactEmail?: string | undefined, contactName?: string | undefined, disableLdap?: boolean | undefined, disableUM?: boolean | undefined, duplicateLDAPGroups?: boolean | undefined, emailDisclaimer?: string | undefined, enableManagedUID?: boolean | undefined, features?: ({directoryInsightsPremium?: ({enabled?: boolean | undefined, createdAt?: string | undefined, updatedAt?: string | undefined}) | undefined, systemInsights?: ({enableNewDarwin?: boolean | undefined, enableNewLinux?: boolean | undefined, enableNewWindows?: boolean | undefined, enabled?: boolean | undefined, createdAt?: string | undefined, updatedAt?: string | undefined}) | undefined, directoryInsights?: ({enabled?: boolean | undefined}) | undefined}) | undefined, growthData?: Record | undefined, logo?: string | undefined, name?: string | undefined, newSystemUserStateDefaults?: ({applicationImport?: ('ACTIVATED' | 'STAGED') | undefined, csvImport?: ('ACTIVATED' | 'STAGED') | undefined, manualEntry?: ('ACTIVATED' | 'STAGED') | undefined}) | undefined, passwordCompliance?: ('custom' | 'pci3' | 'windows') | undefined, passwordPolicy?: ({allowUnenrolledMFAPasswordReset?: boolean | undefined, allowUsernameSubstring?: boolean | undefined, daysAfterExpirationToSelfRecover?: number | undefined, daysBeforeExpirationToForceReset?: number | undefined, disallowCommonlyUsedPasswords?: boolean | undefined, disallowCustomBannedPasswords?: boolean | undefined, disallowNameSubstring?: boolean | undefined, disallowSequentialOrRepetitiveChars?: boolean | undefined, displayComplexityOnResetScreen?: boolean | undefined, effectiveDate?: string | undefined, enableDaysAfterExpirationToSelfRecover?: boolean | undefined, enableDaysBeforeExpirationToForceReset?: boolean | undefined, enableLockoutTimeInSeconds?: boolean | undefined, enableMaxHistory?: boolean | undefined, enableMaxLoginAttempts?: boolean | undefined, enableMinChangePeriodInDays?: boolean | undefined, enableMinLength?: boolean | undefined, enableNameConsecutiveChars?: boolean | undefined, enablePasswordExpirationInDays?: boolean | undefined, gracePeriodDate?: string | undefined, lockoutTimeInSeconds?: number | undefined, maxHistory?: number | undefined, maxLoginAttempts?: number | undefined, minChangePeriodInDays?: number | undefined, minLength?: number | undefined, nameConsecutiveChars?: number | undefined, needsLowercase?: boolean | undefined, needsNumeric?: boolean | undefined, needsSymbolic?: boolean | undefined, needsUppercase?: boolean | undefined, passwordExpirationInDays?: number | undefined}) | undefined, showIntro?: boolean | undefined, systemUserDefaults?: ({restrictedFields?: Array | undefined}) | undefined, systemUserPasswordExpirationInDays?: number | undefined, systemUsersCanEdit?: boolean | undefined, disableGoogleLogin?: boolean | undefined, userPortal?: ({idleSessionDurationMinutes?: number | undefined, cookieExpirationType?: ('session' | 'date') | undefined}) | undefined, deviceIdentificationEnabled?: boolean | undefined, trustedAppConfig?: TrustedappConfigPut | undefined, maxSystemUsers?: number | undefined}; export type UpdateApiApiOrganizationsIdArgs = {body: {settings?: Organizationsettingsput | undefined}}; export type UpdateApiApiOrganizationsIdOptions = {baseUrl?: string | undefined, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const customEmailSettings = z.object({enabled: z.boolean().optional()}); export const organizationentitlement = z.object({billingModel: z.string().optional(), capUserQuantity: z.boolean().optional(), maxUserQuantity: z.number().int().optional(), purchaseChannel: z.string().optional(), entitlementProducts: z.array(z.object({committedUsers: z.number().int().optional(), contractType: z.string().optional(), maxUserCount: z.number().int().optional(), name: z.string().optional(), pricePerUser: z.number().int().optional(), productCategory: z.string().optional(), productCode: z.string().optional(), uncommittedUsers: z.number().int().optional()})).optional(), isManuallyBilled: z.boolean().optional(), pricePerUserSum: z.number().int().optional()}); export const restrictedField = z.object({field: z.enum(["addresses", "company", "costCenter", "department", "description", "displayname", "email", "employeeIdentifier", "employeeType", "firstname", "jobTitle", "lastname", "location", "middlename", "password", "phoneNumbers", "sudo", "username"]).max(32).optional(), type: z.enum(["active_directory", "federated_identity_provider", "scim"]).max(128).optional(), id: z.string().max(24).optional()}); export const trustedappConfigGet = z.object({checksum: z.string(), trustedApps: z.array(z.object({name: z.string(), path: z.string().optional(), teamid: z.string().optional()}))}); export const organizationsettings = z.object({agentVersion: z.string().optional(), betaFeatures: z.object({}).optional(), chromeDTCEnabled: z.boolean().optional(), contactEmail: z.string().optional(), contactName: z.string().optional(), disableCommandRunner: z.boolean().optional(), disableLdap: z.boolean().optional(), disableUM: z.boolean().optional(), duplicateLDAPGroups: z.boolean().optional(), emailDisclaimer: z.string().optional(), enableGoogleApps: z.boolean().optional(), enableManagedUID: z.boolean().optional(), enableO365: z.boolean().optional(), enableUserPortalAgentInstall: z.boolean().optional(), features: z.object({directoryInsightsPremium: z.object({enabled: z.boolean().optional(), createdAt: z.string().optional(), updatedAt: z.string().optional()}).optional(), systemInsights: z.object({enableNewDarwin: z.boolean().optional(), enableNewLinux: z.boolean().optional(), enableNewWindows: z.boolean().optional(), enabled: z.boolean().optional(), createdAt: z.string().optional(), updatedAt: z.string().optional()}).optional(), directoryInsights: z.object({enabled: z.boolean().optional()}).optional()}).optional(), growthData: z.object({}).optional(), logo: z.string().optional(), name: z.string().optional(), newSystemUserStateDefaults: z.object({applicationImport: z.enum(["ACTIVATED", "STAGED"]).optional(), csvImport: z.enum(["ACTIVATED", "STAGED"]).optional(), manualEntry: z.enum(["ACTIVATED", "STAGED"]).optional()}).optional(), passwordCompliance: z.enum(["custom", "pci3", "windows"]).optional(), passwordPolicy: z.object({allowUnenrolledMFAPasswordReset: z.boolean().optional(), allowUsernameSubstring: z.boolean().optional(), daysAfterExpirationToSelfRecover: z.number().int().optional(), daysBeforeExpirationToForceReset: z.number().int().gte(1).optional(), disallowCommonlyUsedPasswords: z.boolean().optional(), disallowCustomBannedPasswords: z.boolean().optional(), disallowNameSubstring: z.boolean().optional(), disallowSequentialOrRepetitiveChars: z.boolean().optional(), displayComplexityOnResetScreen: z.boolean().optional(), effectiveDate: z.string().optional(), enableDaysAfterExpirationToSelfRecover: z.boolean().optional(), enableDaysBeforeExpirationToForceReset: z.boolean().optional(), enableLockoutTimeInSeconds: z.boolean().optional(), enableMaxHistory: z.boolean().optional(), enableMaxLoginAttempts: z.boolean().optional(), enableMinChangePeriodInDays: z.boolean().optional(), enableMinLength: z.boolean().optional(), enableNameConsecutiveChars: z.boolean().optional(), enablePasswordExpirationInDays: z.boolean().optional(), gracePeriodDate: z.string().optional(), lockoutTimeInSeconds: z.number().int().gte(300).lte(5400).optional(), maxHistory: z.number().int().gte(1).lte(24).optional(), maxLoginAttempts: z.number().int().gte(1).optional(), minChangePeriodInDays: z.number().int().optional(), minLength: z.number().int().optional(), nameConsecutiveChars: z.number().int().gte(2).lte(10).optional(), needsLowercase: z.boolean().optional(), needsNumeric: z.boolean().optional(), needsSymbolic: z.boolean().optional(), needsUppercase: z.boolean().optional(), passwordExpirationInDays: z.number().int().gte(1).optional(), enableResetLockoutCounter: z.boolean().optional(), resetLockoutCounterMinutes: z.number().int().gte(1).optional(), enableRecoveryEmail: z.boolean().optional()}).optional(), pendingDelete: z.boolean().optional(), requireAdminMFA: z.boolean().optional(), showIntro: z.boolean().optional(), systemUserDefaults: z.object({restrictedFields: z.array(restrictedField).optional()}).optional(), systemUserPasswordExpirationInDays: z.number().int().optional(), systemUsersCanEdit: z.boolean().optional(), disableGoogleLogin: z.boolean().optional(), userPortal: z.object({idleSessionDurationMinutes: z.number().int().gte(1).lte(129600).optional(), cookieExpirationType: z.enum(["session", "date"]).optional()}).optional(), deviceIdentificationEnabled: z.boolean().optional(), trustedAppConfig: trustedappConfigGet.optional(), maxSystemUsers: z.number().int().gte(0).optional(), windowsMDM: z.object({enabled: z.boolean().optional(), autoEnroll: z.boolean().optional()}).optional()}); export const organization = z.object({_id: z.string().optional(), created: z.string().optional(), customEmailSettings: customEmailSettings.optional(), displayName: z.string().optional(), entitlement: organizationentitlement.optional(), hasStripeCustomerId: z.boolean().optional(), hasCreditCard: z.boolean().optional(), lastEstimateCalculationTimeStamp: z.string().optional(), lastSfdcSyncStatus: z.object({}).optional(), accountsReceivable: z.string().optional(), accessRestriction: z.string().optional(), accountType: z.enum(["Alliance", "Distributor", "MSP", "VAR", "Direct", "Indirect", "Tenant", "Deleted Organization", "Partner", "Customer", "Prospective Customer", "Prospective Partner"]).optional(), logoUrl: z.string().nullable().optional(), provider: z.string().nullable().optional(), settings: organizationsettings.optional(), totalBillingEstimate: z.number().int().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 }; /** * Update an Organization * * PUT /api/organizations/{id} */ export const updateApiApiOrganizationsId = async (args: UpdateApiApiOrganizationsIdArgs, options?: UpdateApiApiOrganizationsIdOptions) => { 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/organizations/${encodeURIComponent(String(args.id))}${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(organization, await res.json()) };