0

List All Droplet Neighbors

by
Published Dec 20, 2024

To retrieve a list of all Droplets that are co-located on the same physical hardware, send a GET request to `/v2/reports/droplet_neighbors_ids`. The results will be returned as a JSON object with a key of `neighbor_ids`. This will be set to an array of arrays. Each array will contain a set of Droplet IDs for Droplets that share a physical server. An empty array indicates that all Droplets associated with your account are located on separate physical hardware.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * List All Droplet Neighbors
7
 * To retrieve a list of all Droplets that are co-located on the same physical
8
hardware, send a GET request to `/v2/reports/droplet_neighbors_ids`.
9

10
The results will be returned as a JSON object with a key of `neighbor_ids`.
11
This will be set to an array of arrays. Each array will contain a set of
12
Droplet IDs for Droplets that share a physical server. An empty array
13
indicates that all Droplets associated with your account are located on
14
separate physical hardware.
15

16
 */
17
export async function main(auth: Digitalocean) {
18
  const url = new URL(
19
    `https://api.digitalocean.com/v2/reports/droplet_neighbors_ids`,
20
  );
21

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