Edits history of script submission #17144 for ' Update a Linode's managed settings (linode)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Linode = {
      token: string;
    };
    /**
     * Update a Linode's managed settings
     * Updates a single Linode's Managed settings.
     */
    export async function main(
      auth: Linode,
      apiVersion: "v4" | "v4beta",
      linodeId: string,
      body: {
        group?: string;
        id?: number;
        label?: string;
        ssh?: { access?: false | true; ip?: string; port?: number; user?: string };
      },
    ) {
      const url = new URL(
        `https://api.linode.com/${apiVersion}/managed/linode-settings/${linodeId}`,
      );
    
      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