1 | |
2 | type Box = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update retention policy |
7 | * Updates a retention policy. |
8 | */ |
9 | export async function main( |
10 | auth: Box, |
11 | retention_policy_id: string, |
12 | body: { |
13 | policy_name?: string; |
14 | description?: string; |
15 | disposition_action?: string; |
16 | retention_type?: string; |
17 | retention_length?: string | number; |
18 | status?: string; |
19 | can_owner_extend_retention?: false | true; |
20 | are_owners_notified?: false | true; |
21 | custom_notification_recipients?: { id: string; type: "user" }[]; |
22 | }, |
23 | ) { |
24 | const url = new URL( |
25 | `https://api.box.com/2.0/retention_policies/${retention_policy_id}`, |
26 | ); |
27 |
|
28 | const response = await fetch(url, { |
29 | method: "PUT", |
30 | headers: { |
31 | "Content-Type": "application/json", |
32 | Authorization: "Bearer " + auth.token, |
33 | }, |
34 | body: JSON.stringify(body), |
35 | }); |
36 | if (!response.ok) { |
37 | const text = await response.text(); |
38 | throw new Error(`${response.status} ${text}`); |
39 | } |
40 | return await response.json(); |
41 | } |
42 |
|