//native
type Cockroachdb = {
token: string;
};
/**
* List all egress rules associated with a cluster
* Sort order: Name
Can be used by the following roles assigned at the organization, folder or cluster scope:
- CLUSTER_ADMIN
- CLUSTER_OPERATOR_WRITER
*/
export async function main(
auth: Cockroachdb,
cluster_id: string,
pagination_page: string | undefined,
pagination_limit: string | undefined,
pagination_as_of_time: string | undefined,
pagination_sort_order: "ASC" | "DESC" | undefined,
) {
const url = new URL(
`https://cockroachlabs.cloud/api/v1/clusters/${cluster_id}/networking/egress-rules`,
);
for (const [k, v] of [
["pagination.page", pagination_page],
["pagination.limit", pagination_limit],
["pagination.as_of_time", pagination_as_of_time],
["pagination.sort_order", pagination_sort_order],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago