//native
type Cockroachdb = {
token: string;
};
/**
* Update a folder
* Can be used by the following roles assigned at the organization or folder scope:
- FOLDER_ADMIN
- FOLDER_MOVER
*/
export async function main(
auth: Cockroachdb,
folder_id: string,
body: { labels?: {}; name?: string; parent_id?: string },
) {
const url = new URL(
`https://cockroachlabs.cloud/api/v1/folders/${folder_id}`,
);
const response = await fetch(url, {
method: "PATCH",
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