0

List All Container Registry Repositories

by
Published Dec 20, 2024

This endpoint has been deprecated in favor of the _List All Container Registry Repositories [V2]_ endpoint. To list all repositories in your container registry, send a GET request to `/v2/registry/$REGISTRY_NAME/repositories`.

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 Container Registry Repositories
7
 * This endpoint has been deprecated in favor of the _List All Container Registry Repositories [V2]_ endpoint.
8

9
To list all repositories in your container registry, send a GET
10
request to `/v2/registry/$REGISTRY_NAME/repositories`.
11

12
 */
13
export async function main(
14
  auth: Digitalocean,
15
  registry_name: string,
16
  per_page: string | undefined,
17
  page: string | undefined,
18
) {
19
  const url = new URL(
20
    `https://api.digitalocean.com/v2/registry/${registry_name}/repositories`,
21
  );
22
  for (const [k, v] of [
23
    ["per_page", per_page],
24
    ["page", page],
25
  ]) {
26
    if (v !== undefined && v !== "" && k !== undefined) {
27
      url.searchParams.append(k, v);
28
    }
29
  }
30
  const response = await fetch(url, {
31
    method: "GET",
32
    headers: {
33
      Authorization: "Bearer " + auth.token,
34
    },
35
    body: undefined,
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43