export type Key = {key: string}; export type CreateApiCustodianKey2Args = {'x-tenant-id'?: string | undefined, body: Key}; export type CreateApiCustodianKey2Options = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Provide Key 2 * * POST /custodian/key2 */ export const createApiCustodianKey2 = async (args: CreateApiCustodianKey2Args, options: CreateApiCustodianKey2Options) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/plain") if (args['x-tenant-id'] != null) headers.set("x-tenant-id", String(args['x-tenant-id'])) const url = `${baseUrl.replace(/\/+$/, '')}/custodian/key2${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 res.text() };