export type CreateApiLicenseEnvironmentIdLicenseFileArgs = {licenseFileName?: string | undefined, overwriteExisting?: boolean | undefined, environmentId: string, body: BodyInit}; export type CreateApiLicenseEnvironmentIdLicenseFileOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Update the license by uploading a new license file * * POST /license/{environmentId}/licenseFile * * Also accepts auth: jwtAuth, oauth2, oauth2 */ export const createApiLicenseEnvironmentIdLicenseFile = async (args: CreateApiLicenseEnvironmentIdLicenseFileArgs, options: CreateApiLicenseEnvironmentIdLicenseFileOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.licenseFileName != null) query.append("licenseFileName", String(args.licenseFileName)) if (args.overwriteExisting != null) query.append("overwriteExisting", String(args.overwriteExisting)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/license/${encodeURIComponent(String(args.environmentId))}/licenseFile${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };