export type ExtendedInformationRestRequestComponent = {name?: string | undefined, value?: string | undefined}; export type AddEndEntityRestRequest = {username?: string | undefined, password?: string | undefined, subject_dn?: string | undefined, subject_alt_name?: string | undefined, email?: string | undefined, extension_data?: Array | undefined, custom_data?: Array | undefined, ca_name?: string | undefined, certificate_profile_name?: string | undefined, end_entity_profile_name?: string | undefined, token?: 'USERGENERATED, P12, JKS, PEM' | undefined, account_binding_id?: string | undefined, key_recoverable?: boolean | undefined, status?: 'NEW, FAILED, INITIALIZED, INPROCESS, GENERATED, REVOKED, HISTORICAL, KEYRECOVERY, WAITINGFORADDAPPROVAL' | undefined, send_notification?: boolean | undefined, start_time?: string | undefined, end_time?: string | undefined, certificate_serial_number?: number | undefined, card_number?: string | undefined}; export type CreateApiV1EndentityArgs = {body: AddEndEntityRestRequest}; export type CreateApiV1EndentityOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Add new end entity, if it does not exist * * POST /v1/endentity */ export const createApiV1Endentity = async (args: CreateApiV1EndentityArgs, options: CreateApiV1EndentityOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/endentity${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 undefined };