diff --git a/cli/src/main.rs b/cli/src/main.rs index c183e35..8054329 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -849,6 +849,8 @@ enum ClustersCommand { Update(UpdateCluster), Delete(DeleteCluster), Expand(ExpandCluster), + Resize(ResizeCluster), + Upgrade(UpgradeCluster), } #[derive(Debug, StructOpt)] @@ -987,6 +989,41 @@ struct ExpandCluster { disk_type: Option, } +#[derive(Debug, StructOpt)] +#[structopt(about = "Resize a cluster")] +struct ResizeCluster { + #[structopt(long, parse(try_from_str = parse_org_id), default_value = "", help = "The organization id the cluster relates to")] + org_id: OrgId, + + #[structopt(long, parse(try_from_str = parse_project_id), default_value = "", help = "The project id the cluster relates to")] + project_id: esc_api::resources::ProjectId, + + #[structopt(long, short, parse(try_from_str = parse_cluster_id), help = "Id of the cluster you want to resize")] + id: esc_api::ClusterId, + + #[structopt(long, help = "The target instance size. (C4, M8, etc)")] + target_size: String, +} + +#[derive(Debug, StructOpt)] +#[structopt(about = "Upgrade a cluster")] +struct UpgradeCluster { + #[structopt(long, parse(try_from_str = parse_org_id), default_value = "", help = "The organization id the cluster relates to")] + org_id: OrgId, + + #[structopt(long, parse(try_from_str = parse_project_id), default_value = "", help = "The project id the cluster relates to")] + project_id: esc_api::resources::ProjectId, + + #[structopt(long, short, parse(try_from_str = parse_cluster_id), help = "Id of the cluster you want to upgrade")] + id: esc_api::ClusterId, + + #[structopt( + long, + help = "The target tag you want to upgrade to. This must include the full version (23.10.1)." + )] + target_tag: String, +} + #[derive(Debug, StructOpt)] #[structopt(about = "Gathers backup management commands")] struct Backups { @@ -2385,6 +2422,34 @@ async fn call_api<'a, 'b>( ) .await?; } + + ClustersCommand::Resize(params) => { + let client = client_builder.create().await?; + esc_api::mesdb::resize_cluster( + &client, + params.org_id, + params.project_id, + params.id, + esc_api::mesdb::ResizeClusterRequest { + target_size: params.target_size, + }, + ) + .await?; + } + + ClustersCommand::Upgrade(params) => { + let client = client_builder.create().await?; + esc_api::mesdb::upgrade_cluster( + &client, + params.org_id, + params.project_id, + params.id, + esc_api::mesdb::UpgradeClusterRequest { + target_tag: params.target_tag, + }, + ) + .await?; + } }, MesdbCommand::Backups(clusters) => match clusters.backups_command { BackupsCommand::Create(params) => { diff --git a/generated/src/mesdb/operations.rs b/generated/src/mesdb/operations.rs index 1ab9f93..a4191db 100644 --- a/generated/src/mesdb/operations.rs +++ b/generated/src/mesdb/operations.rs @@ -234,6 +234,38 @@ pub async fn list_clusters( .await } +/// resize a cluster +/// +/// # Arguments +/// +/// * `organization_id` - The id of the organization the cluster is owned by +/// * `project_id` - The id of the project the cluster is organized by +/// * `cluster_id` - The id of the cluster +/// * `resize_cluster_request` +pub async fn resize_cluster( + client: &Client, + organization_id: OrganizationId, + project_id: ProjectId, + cluster_id: ClusterId, + // describes how to resize the cluster + resize_cluster_request: ResizeClusterRequest, +) -> Result { + let url = format!( + "/mesdb/v1/organizations/{organizationId}/projects/{projectId}/clusters/{clusterId}/commands/resize", + organizationId = urlencode(organization_id), + projectId = urlencode(project_id), + clusterId = urlencode(cluster_id), + ); + client + .send_request::( + Method::PUT, + url, + Some(&resize_cluster_request), + None, + ) + .await +} + /// restart a cluster /// /// # Arguments @@ -289,3 +321,35 @@ pub async fn update_cluster( ) .await } + +/// upgrades a cluster +/// +/// # Arguments +/// +/// * `organization_id` - The id of the organization the cluster is owned by +/// * `project_id` - The id of the project the cluster is organized by +/// * `cluster_id` - The id of the cluster +/// * `upgrade_cluster_request` +pub async fn upgrade_cluster( + client: &Client, + organization_id: OrganizationId, + project_id: ProjectId, + cluster_id: ClusterId, + // describes how to upgrade the cluster + upgrade_cluster_request: UpgradeClusterRequest, +) -> Result { + let url = format!( + "/mesdb/v1/organizations/{organizationId}/projects/{projectId}/clusters/{clusterId}/commands/upgrade", + organizationId = urlencode(organization_id), + projectId = urlencode(project_id), + clusterId = urlencode(cluster_id), + ); + client + .send_request::( + Method::PUT, + url, + Some(&upgrade_cluster_request), + None, + ) + .await +} diff --git a/generated/src/mesdb/schemas.rs b/generated/src/mesdb/schemas.rs index d595c1a..8abf019 100644 --- a/generated/src/mesdb/schemas.rs +++ b/generated/src/mesdb/schemas.rs @@ -50,76 +50,11 @@ pub struct Cluster { pub region: String, pub server_version: String, pub server_version_tag: String, - pub status: ClusterStatus, + pub status: Status, pub topology: Topology, pub protected: bool, } -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub enum ClusterStatus { - #[serde(rename = "provisioning")] - Provisioning, - #[serde(rename = "disks available")] - DisksAvailable, - #[serde(rename = "expanding disks")] - ExpandingDisks, - #[serde(rename = "restarting")] - Restarting, - #[serde(rename = "available")] - Available, - #[serde(rename = "defunct")] - Defunct, - #[serde(rename = "inconsistent")] - Inconsistent, - #[serde(rename = "deleting instances")] - DeletingInstances, - #[serde(rename = "instances deleted")] - InstancesDeleted, - #[serde(rename = "deleting disks")] - DeletingDisks, - #[serde(rename = "deleted")] - Deleted, -} -impl std::fmt::Display for ClusterStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - ClusterStatus::Provisioning => write!(f, "provisioning"), - ClusterStatus::DisksAvailable => write!(f, "disks available"), - ClusterStatus::ExpandingDisks => write!(f, "expanding disks"), - ClusterStatus::Restarting => write!(f, "restarting"), - ClusterStatus::Available => write!(f, "available"), - ClusterStatus::Defunct => write!(f, "defunct"), - ClusterStatus::Inconsistent => write!(f, "inconsistent"), - ClusterStatus::DeletingInstances => write!(f, "deleting instances"), - ClusterStatus::InstancesDeleted => write!(f, "instances deleted"), - ClusterStatus::DeletingDisks => write!(f, "deleting disks"), - ClusterStatus::Deleted => write!(f, "deleted"), - } - } -} -impl std::cmp::PartialEq<&str> for ClusterStatus { - fn eq(&self, other: &&str) -> bool { - match self { - ClusterStatus::Provisioning => *other == "provisioning", - ClusterStatus::DisksAvailable => *other == "disks available", - ClusterStatus::ExpandingDisks => *other == "expanding disks", - ClusterStatus::Restarting => *other == "restarting", - ClusterStatus::Available => *other == "available", - ClusterStatus::Defunct => *other == "defunct", - ClusterStatus::Inconsistent => *other == "inconsistent", - ClusterStatus::DeletingInstances => *other == "deleting instances", - ClusterStatus::InstancesDeleted => *other == "instances deleted", - ClusterStatus::DeletingDisks => *other == "deleting disks", - ClusterStatus::Deleted => *other == "deleted", - } - } -} -impl std::cmp::PartialEq for &str { - fn eq(&self, other: &ClusterStatus) -> bool { - other == self - } -} - #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct CreateBackupRequest { @@ -274,12 +209,94 @@ impl std::cmp::PartialEq for &str { } } +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ResizeClusterRequest { + pub target_size: String, +} + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ResizeClusterResponse { + pub id: String, +} + #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct RestartClusterResponse { pub id: String, } +/// The status of the cluster +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "provisioning")] + Provisioning, + #[serde(rename = "disks available")] + DisksAvailable, + #[serde(rename = "expanding disks")] + ExpandingDisks, + #[serde(rename = "restarting")] + Restarting, + #[serde(rename = "available")] + Available, + #[serde(rename = "defunct")] + Defunct, + #[serde(rename = "inconsistent")] + Inconsistent, + #[serde(rename = "upgrading")] + Upgrading, + #[serde(rename = "deleting instances")] + DeletingInstances, + #[serde(rename = "instances deleted")] + InstancesDeleted, + #[serde(rename = "deleting disks")] + DeletingDisks, + #[serde(rename = "deleted")] + Deleted, +} +impl std::fmt::Display for Status { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Status::Provisioning => write!(f, "provisioning"), + Status::DisksAvailable => write!(f, "disks available"), + Status::ExpandingDisks => write!(f, "expanding disks"), + Status::Restarting => write!(f, "restarting"), + Status::Available => write!(f, "available"), + Status::Defunct => write!(f, "defunct"), + Status::Inconsistent => write!(f, "inconsistent"), + Status::Upgrading => write!(f, "upgrading"), + Status::DeletingInstances => write!(f, "deleting instances"), + Status::InstancesDeleted => write!(f, "instances deleted"), + Status::DeletingDisks => write!(f, "deleting disks"), + Status::Deleted => write!(f, "deleted"), + } + } +} +impl std::cmp::PartialEq<&str> for Status { + fn eq(&self, other: &&str) -> bool { + match self { + Status::Provisioning => *other == "provisioning", + Status::DisksAvailable => *other == "disks available", + Status::ExpandingDisks => *other == "expanding disks", + Status::Restarting => *other == "restarting", + Status::Available => *other == "available", + Status::Defunct => *other == "defunct", + Status::Inconsistent => *other == "inconsistent", + Status::Upgrading => *other == "upgrading", + Status::DeletingInstances => *other == "deleting instances", + Status::InstancesDeleted => *other == "instances deleted", + Status::DeletingDisks => *other == "deleting disks", + Status::Deleted => *other == "deleted", + } + } +} +impl std::cmp::PartialEq for &str { + fn eq(&self, other: &Status) -> bool { + other == self + } +} + /// Either single-node or three-node-multi-zone #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub enum Topology { @@ -318,3 +335,15 @@ pub struct UpdateClusterRequest { #[serde(skip_serializing_if = "Option::is_none")] pub protected: Option, } + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct UpgradeClusterRequest { + pub target_tag: String, +} + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct UpgradeClusterResponse { + pub id: String, +}