export type CertificateSpec = {name?: string | undefined, certificate: string}; export type CertificateSpecUploadInput = {spec_list: Array}; export type CreateApiClustersUuidCertificatesSvmCertsKmsUuidArgs = {uuid: unknown, kms_uuid: unknown, body: CertificateSpecUploadInput}; export type CreateApiClustersUuidCertificatesSvmCertsKmsUuidOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Add one or more certificates to a service VM * * POST /clusters/{uuid}/certificates/svm_certs/{kms_uuid} */ export const createApiClustersUuidCertificatesSvmCertsKmsUuid = async (args: CreateApiClustersUuidCertificatesSvmCertsKmsUuidArgs, options: CreateApiClustersUuidCertificatesSvmCertsKmsUuidOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/clusters/${encodeURIComponent(String(args.uuid))}/certificates/svm_certs/${encodeURIComponent(String(args.kms_uuid))}${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 };