0

Validate App Rollback

by
Published Dec 20, 2024

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.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Validate App Rollback
7
 * Check whether an app can be rolled back to a specific deployment. This endpoint can also be used
8
to check if there are any warnings or validation conditions that will cause the rollback to proceed
9
under unideal circumstances. For example, if a component must be rebuilt as part of the rollback
10
causing it to take longer than usual.
11

12
 */
13
export async function main(
14
  auth: Digitalocean,
15
  app_id: string,
16
  body: { deployment_id?: string; skip_pin?: false | true },
17
) {
18
  const url = new URL(
19
    `https://api.digitalocean.com/v2/apps/${app_id}/rollback/validate`,
20
  );
21

22
  const response = await fetch(url, {
23
    method: "POST",
24
    headers: {
25
      "Content-Type": "application/json",
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: JSON.stringify(body),
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36