0

List physical replication streams

by
Published Oct 17, 2025

Can be used by the following roles assigned at the organization, folder or cluster scope: - CLUSTER_ADMIN - CLUSTER_OPERATOR_WRITER - CLUSTER_DEVELOPER

Script cockroachdb Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Cockroachdb = {
3
  token: string;
4
};
5
/**
6
 * List physical replication streams
7
 * Can be used by the following roles assigned at the organization, folder or cluster scope:
8
- CLUSTER_ADMIN
9
- CLUSTER_OPERATOR_WRITER
10
- CLUSTER_DEVELOPER
11

12
 */
13
export async function main(
14
  auth: Cockroachdb,
15
  primary_cluster_id: string | undefined,
16
  standby_cluster_id: string | undefined,
17
  cluster_id: string | undefined,
18
  show_completed: string | undefined,
19
  pagination_page: string | undefined,
20
  pagination_limit: string | undefined,
21
  pagination_as_of_time: string | undefined,
22
  pagination_sort_order: "ASC" | "DESC" | undefined,
23
) {
24
  const url = new URL(
25
    `https://cockroachlabs.cloud/api/v1/physical-replication-streams`,
26
  );
27
  for (const [k, v] of [
28
    ["primary_cluster_id", primary_cluster_id],
29
    ["standby_cluster_id", standby_cluster_id],
30
    ["cluster_id", cluster_id],
31
    ["show_completed", show_completed],
32
    ["pagination.page", pagination_page],
33
    ["pagination.limit", pagination_limit],
34
    ["pagination.as_of_time", pagination_as_of_time],
35
    ["pagination.sort_order", pagination_sort_order],
36
  ]) {
37
    if (v !== undefined && v !== "" && k !== undefined) {
38
      url.searchParams.append(k, v);
39
    }
40
  }
41
  const response = await fetch(url, {
42
    method: "GET",
43
    headers: {
44
      Authorization: "Bearer " + auth.token,
45
    },
46
    body: undefined,
47
  });
48
  if (!response.ok) {
49
    const text = await response.text();
50
    throw new Error(`${response.status} ${text}`);
51
  }
52
  return await response.json();
53
}
54