Edits history of script submission #17174 for ' Update account settings (linode)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Linode = {
      token: string;
    };
    /**
     * Update account settings
     * Updates your account settings.
     */
    export async function main(
      auth: Linode,
      apiVersion: "v4" | "v4beta",
      body: {
        backups_enabled?: false | true;
        longview_subscription?: string;
        managed?: false | true;
        network_helper?: false | true;
        object_storage?: "disabled" | "suspended" | "active";
      },
    ) {
      const url = new URL(`https://api.linode.com/${apiVersion}/account/settings`);
    
      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