import {z} from 'zod' export type UpdateApiApiRadiusserversIdArgs = {'x-org-id'?: string | undefined, body: {mfa?: ('DISABLED' | 'ENABLED' | 'REQUIRED' | 'ALWAYS') | undefined, name: string, networkSourceIp: string, tags?: Array | undefined, userLockoutAction?: string | undefined, userPasswordExpirationAction?: string | undefined, sharedSecret: string, userPasswordEnabled?: boolean | undefined, userCertEnabled?: boolean | undefined, deviceCertEnabled?: boolean | undefined, caCert?: string | undefined, requireTlsAuth?: boolean | undefined, radsecEnabled?: boolean | undefined, requireRadsec?: boolean | undefined, caSource?: ('NONE' | 'BYOC' | 'JUMPCLOUD_MANAGED') | undefined}}; export type UpdateApiApiRadiusserversIdOptions = {baseUrl?: string | undefined, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const radiusserverput = z.object({_id: z.string().optional(), authIdp: z.enum(["JUMPCLOUD", "AZURE"]).optional(), mfa: z.enum(["DISABLED", "ENABLED", "REQUIRED", "ALWAYS"]).optional(), name: z.string().optional(), networkSourceIp: z.string().optional(), tagNames: z.array(z.string()).optional(), userLockoutAction: z.string().optional(), userPasswordExpirationAction: z.string().optional(), userPasswordEnabled: z.boolean().optional(), userCertEnabled: z.boolean().optional(), deviceCertEnabled: z.boolean().optional(), caCert: z.string().optional(), requireTlsAuth: z.boolean().optional(), radsecEnabled: z.boolean().optional(), requireRadsec: z.boolean().optional(), caSource: z.enum(["NONE", "BYOC", "JUMPCLOUD_MANAGED"]).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 Radius Servers * * PUT /api/radiusservers/{id} */ export const updateApiApiRadiusserversId = async (args: UpdateApiApiRadiusserversIdArgs, options?: UpdateApiApiRadiusserversIdOptions) => { 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 (args['x-org-id'] != null) headers.set("x-org-id", String(args['x-org-id'])) if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/radiusservers/${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(radiusserverput, await res.json()) };