//native
type Linode = {
token: string;
};
/**
* Create an Object Storage bucket
* Creates an Object Storage bucket in the specified data center ([region](https://techdocs.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
body: {
acl?:
| "private"
| "public-read"
| "authenticated-read"
| "public-read-write";
cors_enabled?: false | true;
endpoint_type?: "E0" | "E1" | "E2" | "E3";
label: string;
region?: string;
s3_endpoint?: string;
},
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/object-storage/buckets`,
);
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