Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds subcommand to restart a cluster #71

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ enum ClustersCommand {
Update(UpdateCluster),
Delete(DeleteCluster),
Expand(ExpandCluster),
Restart(RestartCluster),
}

#[derive(Debug, StructOpt)]
Expand Down Expand Up @@ -898,6 +899,19 @@ struct ExpandCluster {
disk_type: Option<String>,
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Restarts a cluster")]
struct RestartCluster {
#[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 expand")]
id: esc_api::ClusterId,
}

#[derive(Debug, StructOpt)]
#[structopt(about = "Gathers backup management commands")]
struct Backups {
Expand Down Expand Up @@ -2211,6 +2225,17 @@ async fn call_api<'a, 'b>(
)
.await?;
}

ClustersCommand::Restart(params) => {
let client = client_builder.create().await?;
esc_api::mesdb::restart_cluster(
&client,
params.org_id,
params.project_id,
params.id,
)
.await?;
}
},
MesdbCommand::Backups(clusters) => match clusters.backups_command {
BackupsCommand::Create(params) => {
Expand Down
24 changes: 24 additions & 0 deletions generated/src/mesdb/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,30 @@ pub async fn list_clusters(
.await
}

/// restart 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
pub async fn restart_cluster(
client: &Client,
organization_id: OrganizationId,
project_id: ProjectId,
cluster_id: ClusterId,
) -> Result<RestartClusterResponse> {
let url = format!(
"/mesdb/v1/organizations/{organizationId}/projects/{projectId}/clusters/{clusterId}/commands/restart",
organizationId = urlencode(organization_id),
projectId = urlencode(project_id),
clusterId = urlencode(cluster_id),
);
client
.send_request::<(), RestartClusterResponse>(Method::PUT, url, None, None)
.await
}

/// Updates a cluster
///
/// # Arguments
Expand Down
6 changes: 6 additions & 0 deletions generated/src/mesdb/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ impl std::fmt::Display for ProjectionLevel {
}
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RestartClusterResponse {
pub id: String,
}

/// Either single-node or three-node-multi-zone
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum Topology {
Expand Down