import {z} from 'zod' export type ConfigureRemotePasswordResetRequest = {operation?: ({Details?: ({RESOURCETYPE: 'Linux' | 'MS SQL Server' | 'SAP' | 'Windows' | 'WindowsDomain', RESOURCEIDS: Array, REMOTEMODE?: ('ssh' | 'telnet') | undefined, LINUX_SSHTELNETPORT?: string | undefined, LINUX_USERPROMPT?: string | undefined, LINUX_LANDINGSERVER?: string | undefined, RESOURCEIDENTIFIER?: string | undefined, REMOTELOGINACCOUNT?: string | undefined, AUTHENTICATION?: ('passauth' | 'keyauth') | undefined, ELEVATIONTYPE?: ('su' | 'sudo') | undefined, ROOTACCOUNT?: string | undefined, LINUXROOTUSERPROMPT?: string | undefined, REMOVEENTER?: string | undefined, MSSQL_AUTHENTICATION?: ('mssql_auth' | 'win_auth') | undefined, MSSQL_PORT?: string | undefined, MSSQL_ACCOUNT?: string | undefined, MSSQL_INSTANCE_NAME?: string | undefined, SAP_SYSTEM_NUMBER?: string | undefined, SAP_ADMIN_ACCOUNT?: string | undefined, ACCOUNTNAME?: string | undefined, ISWINLOCAL?: string | undefined, ISWINDOMAINLOCAL?: string | undefined, WDRESOURCEID?: string | undefined, WDACCOUNTID?: string | undefined, CONNECTION_MODE?: ('SSL' | 'Non SSL') | undefined, WINAUTH_RESOURCE_NAME?: string | undefined, WINAUTH_ACCOUNT_NAME?: string | undefined}) | undefined}) | undefined}; export type CreateApiRestapiJsonV1ResourcesConfigureremotepasswordresetArgs = {orgName?: string | undefined, body: ConfigureRemotePasswordResetRequest}; export type CreateApiRestapiJsonV1ResourcesConfigureremotepasswordresetOptions = {baseUrl?: string | undefined, AuthToken?: string | undefined, fetch?: typeof fetch | undefined}; export const operationResult = z.object({message: z.string().optional(), status: z.string().optional()}); export const configureRemotePasswordResetResponse = z.object({operation: z.object({result: operationResult.optional(), Details: z.object({"CONFIGURATION RESULT": z.array(z.object({MESSAGE: z.string().optional(), STATUS: z.string().optional(), RESOURCENAME: z.string().optional(), RESOURCEID: z.string().optional()})).optional()}).optional(), name: z.string().optional()}).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 }; /** * Configure remote password reset * * POST /restapi/json/v1/resources/configureremotepasswordreset */ export const createApiRestapiJsonV1ResourcesConfigureremotepasswordreset = async (args: CreateApiRestapiJsonV1ResourcesConfigureremotepasswordresetArgs, options?: CreateApiRestapiJsonV1ResourcesConfigureremotepasswordresetOptions) => { const {baseUrl = "https://Hostname:Port", fetch: fetchFn = fetch, AuthToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") headers.set('accept', "application/json") if (args.orgName != null) headers.set("orgName", String(args.orgName)) if (AuthToken !== undefined) headers.set("AUTHTOKEN", AuthToken) const url = `${baseUrl.replace(/\/+$/, '')}/restapi/json/v1/resources/configureremotepasswordreset${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(configureRemotePasswordResetResponse, await res.json()) };