//native
type Linode = {
token: string;
};
/**
* Upload an Object Storage TLS/SSL certificate
* Upload a TLS/SSL certificate and private key to be served when you visit your Object Storage bucket via HTTPS.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
regionId: string,
bucket: string,
body: { certificate: string; private_key: string },
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/object-storage/buckets/${regionId}/${bucket}/ssl`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago