Edits history of script submission #11051 for ' Validate App Rollback (digitalocean)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Digitalocean = {
      token: string;
    };
    /**
     * Validate App Rollback
     * Check whether an app can be rolled back to a specific deployment. This endpoint can also be used
    to check if there are any warnings or validation conditions that will cause the rollback to proceed
    under unideal circumstances. For example, if a component must be rebuilt as part of the rollback
    causing it to take longer than usual.
    
     */
    export async function main(
      auth: Digitalocean,
      app_id: string,
      body: { deployment_id?: string; skip_pin?: false | true },
    ) {
      const url = new URL(
        `https://api.digitalocean.com/v2/apps/${app_id}/rollback/validate`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        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 536 days ago