Edits history of script submission #17139 for ' Suspend a MySQL Managed Database (linode)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Linode = {
      token: string;
    };
    /**
     * Suspend a MySQL Managed Database
     * Suspend a MySQL Managed Database from your account, releasing idle resources and keeping only necessary data.
     */
    export async function main(auth: Linode, apiVersion: "v4", instanceId: string) {
      const url = new URL(
        `https://api.linode.com/${apiVersion}/databases/mysql/instances/${instanceId}/suspend`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        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