//native
type Box = {
token: string;
};
/**
* Update retention policy
* Updates a retention policy.
*/
export async function main(
auth: Box,
retention_policy_id: string,
body: {
policy_name?: string;
description?: string;
disposition_action?: string;
retention_type?: string;
retention_length?: string | number;
status?: string;
can_owner_extend_retention?: false | true;
are_owners_notified?: false | true;
custom_notification_recipients?: { id: string; type: "user" }[];
},
) {
const url = new URL(
`https://api.box.com/2.0/retention_policies/${retention_policy_id}`,
);
const response = await fetch(url, {
method: "PUT",
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