//native
type Cockroachdb = {
token: string;
};
/**
* Update an IP allowlist entry
* 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,
cidr_ip: string,
cidr_mask: string,
body: { name?: string; sql: false | true; ui: false | true },
) {
const url = new URL(
`https://cockroachlabs.cloud/api/v1/clusters/${cluster_id}/networking/allowlist/${cidr_ip}/${cidr_mask}`,
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago