export type ResourceId = string; export type CreateApiSecretsPlaintextArgs = {'decodable-plaintext-base64': string, body: {id: ResourceId}}; export type CreateApiSecretsPlaintextOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get preview results by id. * * POST /secrets/plaintext */ export const createApiSecretsPlaintext = async (args: CreateApiSecretsPlaintextArgs, options?: CreateApiSecretsPlaintextOptions) => { const {baseUrl = "https://replace-with-account.api.data.decodable.co/v1alpha2", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['decodable-plaintext-base64'] != null) headers.set("decodable-plaintext-base64", String(args['decodable-plaintext-base64'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/secrets/plaintext${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 };