Edits history of script submission #14540 for ' Unassign storage policy (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * Unassign storage policy
     * Delete a storage policy assignment.
    
    Deleting a storage policy assignment on a user
    will have the user inherit the enterprise's default
    storage policy.
    
    There is a rate limit for calling this endpoint of only
    twice per user in a 24 hour time frame.
     */
    export async function main(auth: Box, storage_policy_assignment_id: string) {
      const url = new URL(
        `https://api.box.com/2.0/storage_policy_assignments/${storage_policy_assignment_id}`,
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago