//native
type Box = {
token: string;
};
/**
* Force-apply metadata cascade policy to folder
* Force the metadata on a folder with a metadata cascade policy to be applied to
all of its children. This can be used after creating a new cascade policy to
enforce the metadata to be cascaded down to all existing files within that
folder.
*/
export async function main(
auth: Box,
metadata_cascade_policy_id: string,
body: { conflict_resolution: "none" | "overwrite" },
) {
const url = new URL(
`https://api.box.com/2.0/metadata_cascade_policies/${metadata_cascade_policy_id}/apply`,
);
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