Edits history of script submission #17129 for ' Resume a PostgreSQL Managed Database (linode)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Linode = {
      token: string;
    };
    /**
     * Resume a PostgreSQL Managed Database
     * Resume a suspended PostgreSQL Managed Database from your account. This resumes billing for the cluster.
    
    - The user needs `read_write` [user grant](https://techdocs.akamai.com/linode-api/reference/get-user-grants) access to the database.
    
    - The database's status needs to be `suspended`.
    
    
    >
    
    ---
    
    
    - __OAuth scopes__.
    
        ```
        databases:read_write
        ```
    
        [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
     */
    export async function main(auth: Linode, apiVersion: "v4", instanceId: string) {
      const url = new URL(
        `https://api.linode.com/${apiVersion}/databases/postgresql/instances/${instanceId}/resume`,
      );
    
      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