//native
type Cockroachdb = {
token: string;
};
/**
* Scale, edit or upgrade a cluster
* In addition to adding nodes and changing cluster fields, the PATCH Cluster endpoint can be used to upgrade the cluster version.
*/
export async function main(
auth: Cockroachdb,
cluster_id: string,
body: {
cockroach_version?: string;
dedicated?: {
cmek_region_specs?: {
key_spec?: {
auth_principal?: string;
type?: "AWS_KMS" | "GCP_CLOUD_KMS" | "NULL_KMS";
uri?: string;
};
region?: string;
}[];
hardware?: {
disk_iops?: number;
machine_spec?: { machine_type?: string; num_virtual_cpus?: number };
storage_gib?: number;
};
region_nodes?: {};
};
delete_protection?: "ENABLED" | "DISABLED";
labels?: {};
parent_id?: string;
plan?: "BASIC" | "STANDARD" | "ADVANCED";
serverless?: {
primary_region?: string;
regions?: string[];
upgrade_type?: "MANUAL" | "AUTOMATIC";
usage_limits?: {
provisioned_virtual_cpus?: string;
request_unit_limit?: string;
storage_mib_limit?: string;
};
};
upgrade_status?:
| "FINALIZED"
| "MAJOR_UPGRADE_RUNNING"
| "UPGRADE_AVAILABLE"
| "PENDING_FINALIZATION"
| "ROLLBACK_RUNNING";
},
) {
const url = new URL(
`https://cockroachlabs.cloud/api/v1/clusters/${cluster_id}`,
);
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