diff --git a/openstack_cli/src/container_infrastructure_management/v1/certificate/create.rs b/openstack_cli/src/container_infrastructure_management/v1/certificate/create.rs new file mode 100644 index 000000000..8009a4e45 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/certificate/create.rs @@ -0,0 +1,180 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Certificate command +//! +//! Wraps invoking of the `v1/certificates` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use crate::common::parse_json; +use openstack_sdk::api::container_infrastructure_management::v1::certificate::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Sign a new certificate by the CA. +/// +/// | param certificate: | | | --- | --- | | | a certificate within the request +/// body. | +/// +#[derive(Args)] +pub struct CertificateCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + ca_cert_type: Option, + + #[arg(help_heading = "Body parameters", long)] + cluster_uuid: Option, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + #[arg(help_heading = "Body parameters", long)] + csr: Option, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)] + links: Option>, + + #[arg(help_heading = "Body parameters", long)] + pem: Option, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Certificate response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + ca_cert_type: Option, + + #[serde()] + #[structable(optional)] + cluster_uuid: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + csr: Option, + + #[serde()] + #[structable(optional, pretty)] + links: Option, + + #[serde()] + #[structable(optional)] + pem: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl CertificateCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Certificate"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.ca_cert_type data + if let Some(arg) = &self.ca_cert_type { + ep_builder.ca_cert_type(arg); + } + + // Set Request.cluster_uuid data + if let Some(arg) = &self.cluster_uuid { + ep_builder.cluster_uuid(arg); + } + + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.csr data + if let Some(arg) = &self.csr { + ep_builder.csr(arg); + } + + // Set Request.links data + if let Some(arg) = &self.links { + let links_builder: Vec = arg + .iter() + .flat_map(|v| serde_json::from_value::(v.to_owned())) + .collect::>(); + ep_builder.links(links_builder); + } + + // Set Request.pem data + if let Some(arg) = &self.pem { + ep_builder.pem(arg); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/certificate/show.rs b/openstack_cli/src/container_infrastructure_management/v1/certificate/show.rs new file mode 100644 index 000000000..aaf363751 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/certificate/show.rs @@ -0,0 +1,135 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show Certificate command +//! +//! Wraps invoking of the `v1/certificates/{certificate_id}` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::certificate::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Show CA certificate details that are associated with the created cluster +/// based on the given CA certificate type. +/// +#[derive(Args)] +#[command(about = "Show details about the CA certificate for a cluster")] +pub struct CertificateCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// certificate_id parameter for /v1/certificates/{certificate_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Certificate response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + ca_cert_type: Option, + + /// The UUID of the cluster. + /// + #[serde()] + #[structable(optional)] + cluster_uuid: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + csr: Option, + + /// Links to the resources in question. + /// + #[serde()] + #[structable(optional, pretty)] + links: Option, + + /// CA certificate for the cluster. + /// + #[serde()] + #[structable(optional)] + pem: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl CertificateCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show Certificate"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = get::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/action/resize/create.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/action/resize/create.rs new file mode 100644 index 000000000..4e3afd054 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/action/resize/create.rs @@ -0,0 +1,129 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Resize command +//! +//! Wraps invoking of the `v1/clusters/actions/resize` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::cluster::action::resize::create; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// Command without description in OpenAPI +/// +#[derive(Args)] +pub struct ResizeCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + #[arg(help_heading = "Body parameters", long)] + node_count: i32, + + #[arg(help_heading = "Body parameters", long)] + nodegroup: Option, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)] + nodes_to_remove: Option>, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Resize response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable()] + uuid: String, +} + +impl ResizeCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Resize"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.node_count data + ep_builder.node_count(self.node_count); + + // Set Request.nodegroup data + if let Some(arg) = &self.nodegroup { + ep_builder.nodegroup(arg); + } + + // Set Request.nodes_to_remove data + if let Some(arg) = &self.nodes_to_remove { + ep_builder.nodes_to_remove(arg.iter().map(Into::into).collect::>()); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/action/upgrade/create.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/action/upgrade/create.rs new file mode 100644 index 000000000..efd36b246 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/action/upgrade/create.rs @@ -0,0 +1,131 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Upgrade command +//! +//! Wraps invoking of the `v1/clusters/actions/upgrade` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::cluster::action::upgrade::create; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// Command without description in OpenAPI +/// +#[derive(Args)] +pub struct UpgradeCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + cluster_template: Option, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + #[arg(help_heading = "Body parameters", long)] + max_batch_size: Option, + + #[arg(help_heading = "Body parameters", long)] + nodegroup: Option, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Upgrade response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable()] + uuid: String, +} + +impl UpgradeCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Upgrade"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.cluster_template data + if let Some(arg) = &self.cluster_template { + ep_builder.cluster_template(arg); + } + + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.max_batch_size data + if let Some(arg) = &self.max_batch_size { + ep_builder.max_batch_size(*arg); + } + + // Set Request.nodegroup data + if let Some(arg) = &self.nodegroup { + ep_builder.nodegroup(arg); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/create.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/create.rs new file mode 100644 index 000000000..4b1acc9d6 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/create.rs @@ -0,0 +1,510 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Cluster command +//! +//! Wraps invoking of the `v1/clusters` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use crate::common::parse_json; +use crate::common::parse_key_val; +use clap::ValueEnum; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Create new cluster based on cluster template. +/// +#[derive(Args)] +#[command(about = "Create new cluster")] +pub struct ClusterCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + api_address: Option, + + /// The UUID of the cluster template. + /// + #[arg(help_heading = "Body parameters", long)] + cluster_template_id: String, + + #[arg(help_heading = "Body parameters", long)] + coe_version: Option, + + #[arg(help_heading = "Body parameters", long)] + container_version: Option, + + /// The timeout for cluster creation in minutes. The value expected is a + /// positive integer and the default is 60 minutes. If the timeout is + /// reached during cluster creation process, the operation will be aborted + /// and the cluster status will be set to `CREATE_FAILED`. + /// + #[arg(help_heading = "Body parameters", long)] + create_timeout: Option, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + /// The custom discovery url for node discovery. This is used by the COE to + /// discover the servers that have been created to host the containers. The + /// actual discovery mechanism varies with the COE. In some cases, Magnum + /// fills in the server info in the discovery service. In other cases, if + /// the `discovery_url` is not specified, Magnum will use the public + /// discovery service at: + /// + /// ```text + /// https://discovery.etcd.io + /// + /// ``` + /// + /// In this case, Magnum will generate a unique url here for each uster and + /// store the info for the servers. + /// + #[arg(help_heading = "Body parameters", long)] + discovery_url: Option, + + #[arg(help_heading = "Body parameters", long)] + docker_volume_size: Option, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + faults: Option>, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the internal network for the cluster. + /// + #[arg(help_heading = "Body parameters", long)] + fixed_network: Option, + + /// Fixed subnet that are using to allocate network address for nodes in + /// cluster. + /// + #[arg(help_heading = "Body parameters", long)] + fixed_subnet: Option, + + /// The nova flavor ID or name for booting the node servers. The default is + /// `m1.small`. + /// + #[arg(help_heading = "Body parameters", long)] + flavor_id: Option, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. If + /// it’s not set, the value of floating_ip_enabled in template will be + /// used. + /// + #[arg(help_heading = "Body parameters", long)] + floating_ip_enabled: Option, + + #[arg(help_heading = "Body parameters", long)] + health_status: Option, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + health_status_reason: Option>, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[arg(help_heading = "Body parameters", long)] + keypair: Option, + + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels: Option>, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels_added: Option>, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels_overridden: Option>, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels_skipped: Option>, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)] + links: Option>, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)] + master_addresses: Option>, + + /// The number of servers that will serve as master for the cluster. The + /// default is 1. Set to more than 1 master to enable High Availability. If + /// the option `master-lb-enabled` is specified in the cluster template, + /// the master servers will be placed in a load balancer pool. + /// + #[arg(help_heading = "Body parameters", long)] + master_count: Option, + + /// The flavor of the master node for this cluster template. + /// + #[arg(help_heading = "Body parameters", long)] + master_flavor_id: Option, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[arg(help_heading = "Body parameters", long)] + master_lb_enabled: Option, + + #[arg(help_heading = "Body parameters", long)] + merge_labels: Option, + + /// Name of the resource. + /// + #[arg(help_heading = "Body parameters", long)] + name: Option, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)] + node_addresses: Option>, + + /// The number of servers that will serve as node in the cluster. The + /// default is 1. + /// + #[arg(help_heading = "Body parameters", long)] + node_count: Option, + + #[arg(help_heading = "Body parameters", long)] + project_id: Option, + + #[arg(help_heading = "Body parameters", long)] + stack_id: Option, + + #[arg(help_heading = "Body parameters", long)] + status: Option, + + #[arg(help_heading = "Body parameters", long)] + status_reason: Option, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, + + #[arg(help_heading = "Body parameters", long)] + user_id: Option, + + #[arg(help_heading = "Body parameters", long)] + uuid: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Status { + AdoptComplete, + CheckComplete, + CreateComplete, + CreateFailed, + CreateInProgress, + DeleteComplete, + DeleteFailed, + DeleteInProgress, + RestoreComplete, + ResumeComplete, + ResumeFailed, + RollbackComplete, + RollbackFailed, + RollbackInProgress, + SnapshotComplete, + UpdateComplete, + UpdateFailed, + UpdateInProgress, +} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum HealthStatus { + Healthy, + Unhealthy, + Unknown, +} + +/// Cluster response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The UUID of the cluster. + /// + #[serde()] + #[structable()] + uuid: String, +} + +impl ClusterCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Cluster"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.api_address data + if let Some(arg) = &self.api_address { + ep_builder.api_address(arg); + } + + // Set Request.cluster_template_id data + ep_builder.cluster_template_id(&self.cluster_template_id); + + // Set Request.coe_version data + if let Some(arg) = &self.coe_version { + ep_builder.coe_version(arg); + } + + // Set Request.container_version data + if let Some(arg) = &self.container_version { + ep_builder.container_version(arg); + } + + // Set Request.create_timeout data + if let Some(arg) = &self.create_timeout { + ep_builder.create_timeout(*arg); + } + + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.discovery_url data + if let Some(arg) = &self.discovery_url { + ep_builder.discovery_url(arg); + } + + // Set Request.docker_volume_size data + if let Some(arg) = &self.docker_volume_size { + ep_builder.docker_volume_size(*arg); + } + + // Set Request.faults data + if let Some(arg) = &self.faults { + ep_builder.faults(arg.iter().cloned()); + } + + // Set Request.fixed_network data + if let Some(arg) = &self.fixed_network { + ep_builder.fixed_network(arg); + } + + // Set Request.fixed_subnet data + if let Some(arg) = &self.fixed_subnet { + ep_builder.fixed_subnet(arg); + } + + // Set Request.flavor_id data + if let Some(arg) = &self.flavor_id { + ep_builder.flavor_id(arg); + } + + // Set Request.floating_ip_enabled data + if let Some(arg) = &self.floating_ip_enabled { + ep_builder.floating_ip_enabled(arg); + } + + // Set Request.health_status data + if let Some(arg) = &self.health_status { + let tmp = match arg { + HealthStatus::Healthy => create::HealthStatus::Healthy, + HealthStatus::Unhealthy => create::HealthStatus::Unhealthy, + HealthStatus::Unknown => create::HealthStatus::Unknown, + }; + ep_builder.health_status(tmp); + } + + // Set Request.health_status_reason data + if let Some(arg) = &self.health_status_reason { + ep_builder.health_status_reason(arg.iter().cloned()); + } + + // Set Request.keypair data + if let Some(arg) = &self.keypair { + ep_builder.keypair(arg); + } + + // Set Request.labels data + if let Some(arg) = &self.labels { + ep_builder.labels(arg.iter().cloned()); + } + + // Set Request.labels_added data + if let Some(arg) = &self.labels_added { + ep_builder.labels_added(arg.iter().cloned()); + } + + // Set Request.labels_overridden data + if let Some(arg) = &self.labels_overridden { + ep_builder.labels_overridden(arg.iter().cloned()); + } + + // Set Request.labels_skipped data + if let Some(arg) = &self.labels_skipped { + ep_builder.labels_skipped(arg.iter().cloned()); + } + + // Set Request.links data + if let Some(arg) = &self.links { + let links_builder: Vec = arg + .iter() + .flat_map(|v| serde_json::from_value::(v.to_owned())) + .collect::>(); + ep_builder.links(links_builder); + } + + // Set Request.master_addresses data + if let Some(arg) = &self.master_addresses { + ep_builder.master_addresses(arg.iter().map(Into::into).collect::>()); + } + + // Set Request.master_count data + if let Some(arg) = &self.master_count { + ep_builder.master_count(*arg); + } + + // Set Request.master_flavor_id data + if let Some(arg) = &self.master_flavor_id { + ep_builder.master_flavor_id(arg); + } + + // Set Request.master_lb_enabled data + if let Some(arg) = &self.master_lb_enabled { + ep_builder.master_lb_enabled(arg); + } + + // Set Request.merge_labels data + if let Some(arg) = &self.merge_labels { + ep_builder.merge_labels(arg); + } + + // Set Request.name data + if let Some(arg) = &self.name { + ep_builder.name(arg); + } + + // Set Request.node_addresses data + if let Some(arg) = &self.node_addresses { + ep_builder.node_addresses(arg.iter().map(Into::into).collect::>()); + } + + // Set Request.node_count data + if let Some(arg) = &self.node_count { + ep_builder.node_count(*arg); + } + + // Set Request.project_id data + if let Some(arg) = &self.project_id { + ep_builder.project_id(arg); + } + + // Set Request.stack_id data + if let Some(arg) = &self.stack_id { + ep_builder.stack_id(arg); + } + + // Set Request.status data + if let Some(arg) = &self.status { + let tmp = match arg { + Status::AdoptComplete => create::Status::AdoptComplete, + Status::CheckComplete => create::Status::CheckComplete, + Status::CreateComplete => create::Status::CreateComplete, + Status::CreateFailed => create::Status::CreateFailed, + Status::CreateInProgress => create::Status::CreateInProgress, + Status::DeleteComplete => create::Status::DeleteComplete, + Status::DeleteFailed => create::Status::DeleteFailed, + Status::DeleteInProgress => create::Status::DeleteInProgress, + Status::RestoreComplete => create::Status::RestoreComplete, + Status::ResumeComplete => create::Status::ResumeComplete, + Status::ResumeFailed => create::Status::ResumeFailed, + Status::RollbackComplete => create::Status::RollbackComplete, + Status::RollbackFailed => create::Status::RollbackFailed, + Status::RollbackInProgress => create::Status::RollbackInProgress, + Status::SnapshotComplete => create::Status::SnapshotComplete, + Status::UpdateComplete => create::Status::UpdateComplete, + Status::UpdateFailed => create::Status::UpdateFailed, + Status::UpdateInProgress => create::Status::UpdateInProgress, + }; + ep_builder.status(tmp); + } + + // Set Request.status_reason data + if let Some(arg) = &self.status_reason { + ep_builder.status_reason(arg); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + // Set Request.user_id data + if let Some(arg) = &self.user_id { + ep_builder.user_id(arg); + } + + // Set Request.uuid data + if let Some(arg) = &self.uuid { + ep_builder.uuid(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/delete.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/delete.rs new file mode 100644 index 000000000..6b51fe224 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/delete.rs @@ -0,0 +1,100 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete Cluster command +//! +//! Wraps invoking of the `v1/clusters/{cluster_id}` with `DELETE` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use bytes::Bytes; +use http::Response; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::delete; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete a cluster. +/// +#[derive(Args)] +#[command(about = "Delete a cluster")] +pub struct ClusterCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// cluster_id parameter for /v1/clusters/{cluster_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Cluster response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl ClusterCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete Cluster"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = delete::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let _rsp: Response = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/list.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/list.rs new file mode 100644 index 000000000..ef19eab5c --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/list.rs @@ -0,0 +1,260 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List Clusters command +//! +//! Wraps invoking of the `v1/clusters` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::cluster::list; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// List all clusters in Magnum. +/// +#[derive(Args)] +#[command(about = "List all clusters")] +pub struct ClustersCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Clusters response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional, wide)] + api_address: Option, + + /// The UUID of the cluster template. + /// + #[serde()] + #[structable(wide)] + cluster_template_id: String, + + #[serde()] + #[structable(optional, wide)] + coe_version: Option, + + #[serde()] + #[structable(optional, wide)] + container_version: Option, + + /// The timeout for cluster creation in minutes. The value expected is a + /// positive integer and the default is 60 minutes. If the timeout is + /// reached during cluster creation process, the operation will be aborted + /// and the cluster status will be set to `CREATE_FAILED`. + /// + #[serde()] + #[structable(optional, wide)] + create_timeout: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional, wide)] + discovery_url: Option, + + #[serde()] + #[structable(optional, wide)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + faults: Option, + + #[serde()] + #[structable(optional)] + fixed_network: Option, + + #[serde()] + #[structable(optional)] + fixed_subnet: Option, + + #[serde()] + #[structable(optional, wide)] + flavor_id: Option, + + #[serde()] + #[structable(optional)] + floating_ip_enabled: Option, + + #[serde()] + #[structable(optional, wide)] + health_status: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + health_status_reason: Option, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[serde()] + #[structable(optional, wide)] + keypair: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + labels: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_added: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_overridden: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_skipped: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + master_addresses: Option, + + /// The number of servers that will serve as master for the cluster. The + /// default is 1. Set to more than 1 master to enable High Availability. If + /// the option `master-lb-enabled` is specified in the cluster template, + /// the master servers will be placed in a load balancer pool. + /// + #[serde()] + #[structable(optional, wide)] + master_count: Option, + + #[serde()] + #[structable(optional, wide)] + master_flavor_id: Option, + + #[serde()] + #[structable(optional)] + master_lb_enabled: Option, + + #[serde()] + #[structable(optional)] + merge_labels: Option, + + /// Name of the resource. + /// + #[serde()] + #[structable(optional)] + name: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + node_addresses: Option, + + /// The number of servers that will serve as node in the cluster. The + /// default is 1. + /// + #[serde()] + #[structable(optional, wide)] + node_count: Option, + + #[serde()] + #[structable(optional, wide)] + project_id: Option, + + /// The reference UUID of orchestration stack from Heat orchestration + /// service. + /// + #[serde()] + #[structable(optional, wide)] + stack_id: Option, + + /// The current state of the cluster. + /// + #[serde()] + #[structable(optional)] + status: Option, + + #[serde()] + #[structable(optional, wide)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional, wide)] + user_id: Option, + + /// The UUID of the cluster. + /// + #[serde()] + #[structable(optional)] + uuid: Option, +} + +impl ClustersCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Clusters"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/create.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/create.rs new file mode 100644 index 000000000..2fcac8ca5 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/create.rs @@ -0,0 +1,457 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Nodegroup command +//! +//! Wraps invoking of the `v1/clusters/nodegroups` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use crate::common::parse_json; +use crate::common::parse_key_val; +use clap::ValueEnum; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::nodegroup::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Retrieve a list of nodegroups. +/// +/// | param cluster_id: | | | --- | --- | | | the cluster id or name | | param +/// marker: | pagination marker for large data sets. | | param limit: | maximum +/// number of resources to return in a single result. | | param sort_key: | +/// column to sort results by. Default: id. | | param sort_dir: | direction to +/// sort. "asc" or "desc". Default: asc. | | param role: | list all nodegroups +/// with the specified role. | +/// +#[derive(Args)] +pub struct NodegroupCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + cluster_id: Option, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + #[arg(help_heading = "Body parameters", long)] + docker_volume_size: Option, + + #[arg(help_heading = "Body parameters", long)] + flavor_id: Option, + + #[arg(help_heading = "Body parameters", long)] + id: Option, + + #[arg(help_heading = "Body parameters", long)] + image_id: Option, + + #[arg(help_heading = "Body parameters", long)] + is_default: Option, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels: Option>, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels_added: Option>, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels_overridden: Option>, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels_skipped: Option>, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)] + links: Option>, + + #[arg(help_heading = "Body parameters", long)] + max_node_count: Option, + + #[arg(help_heading = "Body parameters", long)] + merge_labels: Option, + + #[arg(help_heading = "Body parameters", long)] + min_node_count: Option, + + #[arg(help_heading = "Body parameters", long)] + name: Option, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)] + node_addresses: Option>, + + #[arg(help_heading = "Body parameters", long)] + node_count: Option, + + #[arg(help_heading = "Body parameters", long)] + project_id: Option, + + #[arg(help_heading = "Body parameters", long)] + role: Option, + + #[arg(help_heading = "Body parameters", long)] + stack_id: Option, + + #[arg(help_heading = "Body parameters", long)] + status: Option, + + #[arg(help_heading = "Body parameters", long)] + status_reason: Option, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, + + #[arg(help_heading = "Body parameters", long)] + uuid: Option, + + #[arg(help_heading = "Body parameters", long)] + version: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Status { + AdoptComplete, + CheckComplete, + CreateComplete, + CreateFailed, + CreateInProgress, + DeleteComplete, + DeleteFailed, + DeleteInProgress, + RestoreComplete, + ResumeComplete, + ResumeFailed, + RollbackComplete, + RollbackFailed, + RollbackInProgress, + SnapshotComplete, + UpdateComplete, + UpdateFailed, + UpdateInProgress, +} + +/// Nodegroup response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + cluster_id: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional)] + flavor_id: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional)] + image_id: Option, + + #[serde()] + #[structable(optional)] + is_default: Option, + + #[serde()] + #[structable(optional, pretty)] + labels: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_added: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_overridden: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_skipped: Option, + + #[serde()] + #[structable(optional, pretty)] + links: Option, + + #[serde()] + #[structable(optional)] + max_node_count: Option, + + #[serde()] + #[structable(optional)] + merge_labels: Option, + + #[serde()] + #[structable(optional)] + min_node_count: Option, + + #[serde()] + #[structable(optional)] + name: Option, + + #[serde()] + #[structable(optional, pretty)] + node_addresses: Option, + + #[serde()] + #[structable(optional)] + node_count: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + #[serde()] + #[structable(optional)] + role: Option, + + #[serde()] + #[structable(optional)] + stack_id: Option, + + #[serde()] + #[structable(optional)] + status: Option, + + #[serde()] + #[structable(optional)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + uuid: Option, + + #[serde()] + #[structable(optional)] + version: Option, +} + +impl NodegroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Nodegroup"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.cluster_id data + if let Some(arg) = &self.cluster_id { + ep_builder.cluster_id(arg); + } + + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.docker_volume_size data + if let Some(arg) = &self.docker_volume_size { + ep_builder.docker_volume_size(*arg); + } + + // Set Request.flavor_id data + if let Some(arg) = &self.flavor_id { + ep_builder.flavor_id(arg); + } + + // Set Request.id data + if let Some(arg) = &self.id { + ep_builder.id(*arg); + } + + // Set Request.image_id data + if let Some(arg) = &self.image_id { + ep_builder.image_id(arg); + } + + // Set Request.is_default data + if let Some(arg) = &self.is_default { + ep_builder.is_default(arg); + } + + // Set Request.labels data + if let Some(arg) = &self.labels { + ep_builder.labels(arg.iter().cloned()); + } + + // Set Request.labels_added data + if let Some(arg) = &self.labels_added { + ep_builder.labels_added(arg.iter().cloned()); + } + + // Set Request.labels_overridden data + if let Some(arg) = &self.labels_overridden { + ep_builder.labels_overridden(arg.iter().cloned()); + } + + // Set Request.labels_skipped data + if let Some(arg) = &self.labels_skipped { + ep_builder.labels_skipped(arg.iter().cloned()); + } + + // Set Request.links data + if let Some(arg) = &self.links { + let links_builder: Vec = arg + .iter() + .flat_map(|v| serde_json::from_value::(v.to_owned())) + .collect::>(); + ep_builder.links(links_builder); + } + + // Set Request.max_node_count data + if let Some(arg) = &self.max_node_count { + ep_builder.max_node_count(*arg); + } + + // Set Request.merge_labels data + if let Some(arg) = &self.merge_labels { + ep_builder.merge_labels(arg); + } + + // Set Request.min_node_count data + if let Some(arg) = &self.min_node_count { + ep_builder.min_node_count(*arg); + } + + // Set Request.name data + if let Some(arg) = &self.name { + ep_builder.name(arg); + } + + // Set Request.node_addresses data + if let Some(arg) = &self.node_addresses { + ep_builder.node_addresses(arg.iter().map(Into::into).collect::>()); + } + + // Set Request.node_count data + if let Some(arg) = &self.node_count { + ep_builder.node_count(*arg); + } + + // Set Request.project_id data + if let Some(arg) = &self.project_id { + ep_builder.project_id(arg); + } + + // Set Request.role data + if let Some(arg) = &self.role { + ep_builder.role(arg); + } + + // Set Request.stack_id data + if let Some(arg) = &self.stack_id { + ep_builder.stack_id(arg); + } + + // Set Request.status data + if let Some(arg) = &self.status { + let tmp = match arg { + Status::AdoptComplete => create::Status::AdoptComplete, + Status::CheckComplete => create::Status::CheckComplete, + Status::CreateComplete => create::Status::CreateComplete, + Status::CreateFailed => create::Status::CreateFailed, + Status::CreateInProgress => create::Status::CreateInProgress, + Status::DeleteComplete => create::Status::DeleteComplete, + Status::DeleteFailed => create::Status::DeleteFailed, + Status::DeleteInProgress => create::Status::DeleteInProgress, + Status::RestoreComplete => create::Status::RestoreComplete, + Status::ResumeComplete => create::Status::ResumeComplete, + Status::ResumeFailed => create::Status::ResumeFailed, + Status::RollbackComplete => create::Status::RollbackComplete, + Status::RollbackFailed => create::Status::RollbackFailed, + Status::RollbackInProgress => create::Status::RollbackInProgress, + Status::SnapshotComplete => create::Status::SnapshotComplete, + Status::UpdateComplete => create::Status::UpdateComplete, + Status::UpdateFailed => create::Status::UpdateFailed, + Status::UpdateInProgress => create::Status::UpdateInProgress, + }; + ep_builder.status(tmp); + } + + // Set Request.status_reason data + if let Some(arg) = &self.status_reason { + ep_builder.status_reason(arg); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + // Set Request.uuid data + if let Some(arg) = &self.uuid { + ep_builder.uuid(arg); + } + + // Set Request.version data + if let Some(arg) = &self.version { + ep_builder.version(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/delete.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/delete.rs new file mode 100644 index 000000000..4616aa51c --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/delete.rs @@ -0,0 +1,102 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete Nodegroup command +//! +//! Wraps invoking of the `v1/clusters/nodegroups/{nodegroup_id}` with `DELETE` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use bytes::Bytes; +use http::Response; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::nodegroup::delete; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete NodeGroup for a given project_id and resource. +/// +/// | param cluster_id: | | | --- | --- | | | cluster id. | | param +/// nodegroup_id: | | | | resource name. | +/// +#[derive(Args)] +pub struct NodegroupCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// nodegroup_id parameter for /v1/clusters/nodegroups/{nodegroup_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Nodegroup response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl NodegroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete Nodegroup"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = delete::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let _rsp: Response = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/delete_all.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/delete_all.rs new file mode 100644 index 000000000..08bd4abde --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/delete_all.rs @@ -0,0 +1,92 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete Nodegroup command +//! +//! Wraps invoking of the `v1/clusters/nodegroups` with `DELETE` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use bytes::Bytes; +use http::Response; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::nodegroup::delete_all; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete NodeGroup for a given project_id and resource. +/// +/// | param cluster_id: | | | --- | --- | | | cluster id. | | param +/// nodegroup_id: | | | | resource name. | +/// +#[derive(Args)] +pub struct NodegroupCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Nodegroup response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl NodegroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete Nodegroup"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = delete_all::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let _rsp: Response = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/list.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/list.rs new file mode 100644 index 000000000..c228e5c83 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/list.rs @@ -0,0 +1,197 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List Nodegroups command +//! +//! Wraps invoking of the `v1/clusters/nodegroups` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::cluster::nodegroup::list; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Retrieve a list of nodegroups. +/// +/// | param cluster_id: | | | --- | --- | | | the cluster id or name | | param +/// marker: | pagination marker for large data sets. | | param limit: | maximum +/// number of resources to return in a single result. | | param sort_key: | +/// column to sort results by. Default: id. | | param sort_dir: | direction to +/// sort. "asc" or "desc". Default: asc. | | param role: | list all nodegroups +/// with the specified role. | +/// +#[derive(Args)] +pub struct NodegroupsCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Nodegroups response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional, wide)] + cluster_id: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional, wide)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional, wide)] + flavor_id: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional, wide)] + image_id: Option, + + #[serde()] + #[structable(optional, wide)] + is_default: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + labels: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + labels_added: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + labels_overridden: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + labels_skipped: Option, + + #[serde()] + #[structable(optional, wide)] + max_node_count: Option, + + #[serde()] + #[structable(optional, wide)] + merge_labels: Option, + + #[serde()] + #[structable(optional, wide)] + min_node_count: Option, + + #[serde()] + #[structable(optional)] + name: Option, + + #[serde()] + #[structable(optional, pretty, wide)] + node_addresses: Option, + + #[serde()] + #[structable(optional, wide)] + node_count: Option, + + #[serde()] + #[structable(optional, wide)] + project_id: Option, + + #[serde()] + #[structable(optional, wide)] + role: Option, + + #[serde()] + #[structable(optional, wide)] + stack_id: Option, + + #[serde()] + #[structable(optional)] + status: Option, + + #[serde()] + #[structable(optional, wide)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + uuid: Option, + + #[serde()] + #[structable(optional, wide)] + version: Option, +} + +impl NodegroupsCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Nodegroups"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/set.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/set.rs new file mode 100644 index 000000000..260440f95 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/set.rs @@ -0,0 +1,259 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Set Nodegroup command +//! +//! Wraps invoking of the `v1/clusters/nodegroups/{nodegroup_id}` with `PATCH` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use clap::ValueEnum; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::nodegroup::find; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::nodegroup::set; +use openstack_sdk::api::find; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Update NodeGroup. +/// +/// | param cluster_id: | | | --- | --- | | | cluster id. | +/// +/// System Message: WARNING/2 (, line 4) +/// +/// Field list ends without a blank line; unexpected unindent. +/// +/// :param : resource name. :param values: a json document to update a +/// nodegroup. +/// +#[derive(Args)] +pub struct NodegroupCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + op: Op, + + #[arg(help_heading = "Body parameters", long)] + path: String, + + #[arg(help_heading = "Body parameters", long)] + value: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// nodegroup_id parameter for /v1/clusters/nodegroups/{nodegroup_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Op { + Add, + Remove, + Replace, +} + +/// Nodegroup response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + cluster_id: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional)] + flavor_id: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional)] + image_id: Option, + + #[serde()] + #[structable(optional)] + is_default: Option, + + #[serde()] + #[structable(optional, pretty)] + labels: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_added: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_overridden: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_skipped: Option, + + #[serde()] + #[structable(optional, pretty)] + links: Option, + + #[serde()] + #[structable(optional)] + max_node_count: Option, + + #[serde()] + #[structable(optional)] + merge_labels: Option, + + #[serde()] + #[structable(optional)] + min_node_count: Option, + + #[serde()] + #[structable(optional)] + name: Option, + + #[serde()] + #[structable(optional, pretty)] + node_addresses: Option, + + #[serde()] + #[structable(optional)] + node_count: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + #[serde()] + #[structable(optional)] + role: Option, + + #[serde()] + #[structable(optional)] + stack_id: Option, + + #[serde()] + #[structable(optional)] + status: Option, + + #[serde()] + #[structable(optional)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + uuid: Option, + + #[serde()] + #[structable(optional)] + version: Option, +} + +impl NodegroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Set Nodegroup"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut find_builder = find::Request::builder(); + + find_builder.id(&self.path.id); + let find_ep = find_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + let find_data: serde_json::Value = find(find_ep).query_async(client).await?; + + let mut ep_builder = set::Request::builder(); + + // Set path parameters + let resource_id = find_data["id"] + .as_str() + .expect("Resource ID is a string") + .to_string(); + ep_builder.id(resource_id.clone()); + // Set query parameters + // Set body parameters + // Set Request.op data + let tmp = match &self.op { + Op::Add => set::Op::Add, + Op::Remove => set::Op::Remove, + Op::Replace => set::Op::Replace, + }; + ep_builder.op(tmp); + + // Set Request.path data + ep_builder.path(&self.path); + + // Set Request.value data + if let Some(arg) = &self.value { + ep_builder.value(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/show.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/show.rs new file mode 100644 index 000000000..8e413587a --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/nodegroup/show.rs @@ -0,0 +1,203 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show Nodegroup command +//! +//! Wraps invoking of the `v1/clusters/nodegroups/{nodegroup_id}` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::cluster::nodegroup::find; +use openstack_sdk::api::find; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Retrieve information for the given nodegroup in a cluster. +/// +/// | | | | --- | --- | | param id: | cluster id. | | param resource: | +/// nodegroup id. | +/// +#[derive(Args)] +pub struct NodegroupCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// nodegroup_id parameter for /v1/clusters/nodegroups/{nodegroup_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Nodegroup response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + cluster_id: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional)] + flavor_id: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional)] + image_id: Option, + + #[serde()] + #[structable(optional)] + is_default: Option, + + #[serde()] + #[structable(optional, pretty)] + labels: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_added: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_overridden: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_skipped: Option, + + #[serde()] + #[structable(optional, pretty)] + links: Option, + + #[serde()] + #[structable(optional)] + max_node_count: Option, + + #[serde()] + #[structable(optional)] + merge_labels: Option, + + #[serde()] + #[structable(optional)] + min_node_count: Option, + + #[serde()] + #[structable(optional)] + name: Option, + + #[serde()] + #[structable(optional, pretty)] + node_addresses: Option, + + #[serde()] + #[structable(optional)] + node_count: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + #[serde()] + #[structable(optional)] + role: Option, + + #[serde()] + #[structable(optional)] + stack_id: Option, + + #[serde()] + #[structable(optional)] + status: Option, + + #[serde()] + #[structable(optional)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + uuid: Option, + + #[serde()] + #[structable(optional)] + version: Option, +} + +impl NodegroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show Nodegroup"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut find_builder = find::Request::builder(); + + find_builder.id(&self.path.id); + let find_ep = find_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + let find_data: serde_json::Value = find(find_ep).query_async(client).await?; + + op.output_single::(find_data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/set.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/set.rs new file mode 100644 index 000000000..bd7b933be --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/set.rs @@ -0,0 +1,148 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Set Cluster command +//! +//! Wraps invoking of the `v1/clusters/{cluster_id}` with `PATCH` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use clap::ValueEnum; +use openstack_sdk::api::container_infrastructure_management::v1::cluster::set; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// Update information of one cluster attributes using operations including: +/// `add`, `replace` or `remove`. The attributes to `add` and `replace` in the +/// form of `key=value` while `remove` only needs the keys. +/// +#[derive(Args)] +#[command(about = "Update information of cluster")] +pub struct ClusterCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + /// The operation used to modify resource’s attributes. Supported + /// operations are following: `add`, `replace` and `remove`. In case of + /// `remove`, users only need to provide `path` for deleting attribute. + /// + #[arg(help_heading = "Body parameters", long)] + op: Op, + + /// Resource attribute’s name. + /// + #[arg(help_heading = "Body parameters", long)] + path: String, + + /// Resource attribute’s value. + /// + #[arg(help_heading = "Body parameters", long)] + value: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// cluster_id parameter for /v1/clusters/{cluster_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Op { + Add, + Remove, + Replace, +} + +/// Cluster response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The UUID of the cluster. + /// + #[serde()] + #[structable()] + uuid: String, +} + +impl ClusterCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Set Cluster"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = set::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + // Set Request.op data + let tmp = match &self.op { + Op::Add => set::Op::Add, + Op::Remove => set::Op::Remove, + Op::Replace => set::Op::Replace, + }; + ep_builder.op(tmp); + + // Set Request.path data + ep_builder.path(&self.path); + + // Set Request.value data + if let Some(arg) = &self.value { + ep_builder.value(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/cluster/show.rs b/openstack_cli/src/container_infrastructure_management/v1/cluster/show.rs new file mode 100644 index 000000000..8f052801b --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/cluster/show.rs @@ -0,0 +1,315 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show Cluster command +//! +//! Wraps invoking of the `v1/clusters/{cluster_id}` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::cluster::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Get all information of a cluster in Magnum. +/// +#[derive(Args)] +#[command(about = "Show details of a cluster")] +pub struct ClusterCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// cluster_id parameter for /v1/clusters/{cluster_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Cluster response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The endpoint URL of COE API exposed to end-users. + /// + #[serde()] + #[structable(optional)] + api_address: Option, + + /// The UUID of the cluster template. + /// + #[serde()] + #[structable()] + cluster_template_id: String, + + /// Version info of chosen COE in cluster for helping client in picking the + /// right version of client. + /// + #[serde()] + #[structable(optional)] + coe_version: Option, + + #[serde()] + #[structable(optional)] + container_version: Option, + + /// The timeout for cluster creation in minutes. The value expected is a + /// positive integer and the default is 60 minutes. If the timeout is + /// reached during cluster creation process, the operation will be aborted + /// and the cluster status will be set to `CREATE_FAILED`. + /// + #[serde()] + #[structable(optional)] + create_timeout: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + /// The custom discovery url for node discovery. This is used by the COE to + /// discover the servers that have been created to host the containers. The + /// actual discovery mechanism varies with the COE. In some cases, Magnum + /// fills in the server info in the discovery service. In other cases, if + /// the `discovery_url` is not specified, Magnum will use the public + /// discovery service at: + /// + /// ```text + /// https://discovery.etcd.io + /// + /// ``` + /// + /// In this case, Magnum will generate a unique url here for each uster and + /// store the info for the servers. + /// + #[serde()] + #[structable(optional)] + discovery_url: Option, + + #[serde()] + #[structable(optional)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional, pretty)] + faults: Option, + + #[serde()] + #[structable(optional)] + fixed_network: Option, + + #[serde()] + #[structable(optional)] + fixed_subnet: Option, + + #[serde()] + #[structable(optional)] + flavor_id: Option, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. If + /// it’s not set, the value of floating_ip_enabled in template will be + /// used. + /// + #[serde()] + #[structable(optional)] + floating_ip_enabled: Option, + + #[serde()] + #[structable(optional)] + health_status: Option, + + #[serde()] + #[structable(optional, pretty)] + health_status_reason: Option, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[serde()] + #[structable(optional)] + keypair: Option, + + #[serde()] + #[structable(optional, pretty)] + labels: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_added: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_overridden: Option, + + #[serde()] + #[structable(optional, pretty)] + labels_skipped: Option, + + /// Links to the resources in question. + /// + #[serde()] + #[structable(optional, pretty)] + links: Option, + + /// List of floating IP of all master nodes. + /// + #[serde()] + #[structable(optional, pretty)] + master_addresses: Option, + + /// The number of servers that will serve as master for the cluster. The + /// default is 1. Set to more than 1 master to enable High Availability. If + /// the option `master-lb-enabled` is specified in the cluster template, + /// the master servers will be placed in a load balancer pool. + /// + #[serde()] + #[structable(optional)] + master_count: Option, + + #[serde()] + #[structable(optional)] + master_flavor_id: Option, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[serde()] + #[structable(optional)] + master_lb_enabled: Option, + + #[serde()] + #[structable(optional)] + merge_labels: Option, + + /// Name of the resource. + /// + #[serde()] + #[structable(optional)] + name: Option, + + /// List of floating IP of all servers that serve as node. + /// + #[serde()] + #[structable(optional, pretty)] + node_addresses: Option, + + /// The number of servers that will serve as node in the cluster. The + /// default is 1. + /// + #[serde()] + #[structable(optional)] + node_count: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + /// The reference UUID of orchestration stack from Heat orchestration + /// service. + /// + #[serde()] + #[structable(optional)] + stack_id: Option, + + /// The current state of the cluster. + /// + #[serde()] + #[structable(optional)] + status: Option, + + /// The reason of cluster current status. + /// + #[serde()] + #[structable(optional)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + user_id: Option, + + /// The UUID of the cluster. + /// + #[serde()] + #[structable(optional)] + uuid: Option, +} + +impl ClusterCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show Cluster"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = get::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/create.rs b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/create.rs new file mode 100644 index 000000000..ebcfccc55 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/create.rs @@ -0,0 +1,793 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Clustertemplate command +//! +//! Wraps invoking of the `v1/clustertemplates` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use crate::common::parse_json; +use crate::common::parse_key_val; +use clap::ValueEnum; +use openstack_sdk::api::container_infrastructure_management::v1::clustertemplate::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Create new cluster template. +/// +#[derive(Args)] +#[command(about = "Create new cluster template")] +pub struct ClustertemplateCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + apiserver_port: Option, + + #[arg(help_heading = "Body parameters", long)] + cluster_distro: Option, + + /// Specify the Container Orchestration Engine to use. Supported COEs + /// include `kubernetes`. If your environment has additional cluster + /// drivers installed, refer to the cluster driver documentation for the + /// new COE names. + /// + #[arg(help_heading = "Body parameters", long)] + coe: Option, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + /// The DNS nameserver for the servers and containers in the cluster to + /// use. This is configured in the private Neutron network for the cluster. + /// The default is `8.8.8.8`. + /// + #[arg(help_heading = "Body parameters", long)] + dns_nameserver: Option, + + /// The name of a driver to manage the storage for the images and the + /// container’s writable layer. The default is `devicemapper`. + /// + #[arg(help_heading = "Body parameters", long)] + docker_storage_driver: Option, + + /// The size in GB for the local storage on each server for the Docker + /// daemon to cache the images and host the containers. Cinder volumes + /// provide the storage. The default is 25 GB. For the `devicemapper` + /// storage driver, the minimum value is 3GB. For the `overlay` storage + /// driver, the minimum value is 1GB. + /// + #[arg(help_heading = "Body parameters", long)] + docker_volume_size: Option, + + #[arg(help_heading = "Body parameters", long)] + driver: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the external internet for the cluster. This network must be an external + /// network, i.e. its attribute `router:external` must be `True`. The + /// servers in the cluster will be connected to a private network and + /// Magnum will create a router between this private network and the + /// external network. This will allow the servers to download images, + /// access discovery service, etc, and the containers to install packages, + /// etc. In the opposite direction, floating IPs will be allocated from the + /// external network to provide access from the external internet to + /// servers and the container services hosted in the cluster. + /// + #[arg(help_heading = "Body parameters", long)] + external_network_id: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the internal network for the cluster. + /// + #[arg(help_heading = "Body parameters", long)] + fixed_network: Option, + + /// Fixed subnet that are using to allocate network address for nodes in + /// cluster. + /// + #[arg(help_heading = "Body parameters", long)] + fixed_subnet: Option, + + /// The nova flavor ID or name for booting the node servers. The default is + /// `m1.small`. + /// + #[arg(help_heading = "Body parameters", long)] + flavor_id: Option, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. + /// + #[arg(help_heading = "Body parameters", long)] + floating_ip_enabled: Option, + + /// Indicates whether the ClusterTemplate is hidden or not, the default + /// value is false. + /// + #[arg(help_heading = "Body parameters", long)] + hidden: Option, + + /// The IP address for a proxy to use when direct http access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[arg(help_heading = "Body parameters", long)] + http_proxy: Option, + + /// The IP address for a proxy to use when direct https access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[arg(help_heading = "Body parameters", long)] + https_proxy: Option, + + /// The name or UUID of the base image in Glance to boot the servers for + /// the cluster. The image must have the attribute `os_distro` defined as + /// appropriate for the cluster driver. + /// + #[arg(help_heading = "Body parameters", long)] + image_id: String, + + #[arg(help_heading = "Body parameters", long)] + insecure_registry: Option, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[arg(help_heading = "Body parameters", long)] + keypair_id: Option, + + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + labels: Option>, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)] + links: Option>, + + /// The flavor of the master node for this cluster template. + /// + #[arg(help_heading = "Body parameters", long)] + master_flavor_id: Option, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[arg(help_heading = "Body parameters", long)] + master_lb_enabled: Option, + + /// Name of the resource. + /// + #[arg(help_heading = "Body parameters", long)] + name: Option, + + /// The name of a network driver for providing the networks for the + /// containers. Note that this is different and separate from the Neutron + /// network for the cluster. The operation and networking model are + /// specific to the particular driver. + /// + #[arg(help_heading = "Body parameters", long)] + network_driver: Option, + + /// When a proxy server is used, some sites should not go through the proxy + /// and should be accessed normally. In this case, users can specify these + /// sites as a comma separated list of IPs. The default is `None`. + /// + #[arg(help_heading = "Body parameters", long)] + no_proxy: Option, + + #[arg(help_heading = "Body parameters", long)] + project_id: Option, + + /// Access to a cluster template is normally limited to the admin, owner or + /// users within the same tenant as the owners. Setting this flag makes the + /// cluster template public and accessible by other users. The default is + /// not public. + /// + #[arg(help_heading = "Body parameters", long)] + public: Option, + + /// Docker images by default are pulled from the public Docker registry, + /// but in some cases, users may want to use a private registry. This + /// option provides an alternative registry based on the Registry V2: + /// Magnum will create a local registry in the cluster backed by swift to + /// host the images. The default is to use the public registry. + /// + #[arg(help_heading = "Body parameters", long)] + registry_enabled: Option, + + /// The servers in the cluster can be `vm` or `baremetal`. This parameter + /// selects the type of server to create for the cluster. The default is + /// `vm`. + /// + #[arg(help_heading = "Body parameters", long)] + server_type: Option, + + /// Administrator tags for the cluster template. + /// + #[arg(help_heading = "Body parameters", long)] + tags: Option, + + /// Transport Layer Security (TLS) is normally enabled to secure the + /// cluster. In some cases, users may want to disable TLS in the cluster, + /// for instance during development or to troubleshoot certain problems. + /// Specifying this parameter will disable TLS so that users can access the + /// COE endpoints without a certificate. The default is TLS enabled. + /// + #[arg(help_heading = "Body parameters", long)] + tls_disabled: Option, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, + + #[arg(help_heading = "Body parameters", long)] + user_id: Option, + + #[arg(help_heading = "Body parameters", long)] + uuid: Option, + + /// The name of a volume driver for managing the persistent storage for the + /// containers. The functionality supported are specific to the driver. + /// + #[arg(help_heading = "Body parameters", long)] + volume_driver: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Coe { + Kubernetes, +} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum ServerType { + Bm, + Vm, +} + +/// Clustertemplate response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The exposed port of COE API server. + /// + #[serde()] + #[structable(optional)] + apiserver_port: Option, + + /// Display the attribute `os_distro` defined as appropriate metadata in + /// image for the cluster driver. + /// + #[serde()] + #[structable(optional)] + cluster_distro: Option, + + /// Specify the Container Orchestration Engine to use. Supported COEs + /// include `kubernetes`. If your environment has additional cluster + /// drivers installed, refer to the cluster driver documentation for the + /// new COE names. + /// + #[serde()] + #[structable(optional)] + coe: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + /// The DNS nameserver for the servers and containers in the cluster to + /// use. This is configured in the private Neutron network for the cluster. + /// The default is `8.8.8.8`. + /// + #[serde()] + #[structable(optional)] + dns_nameserver: Option, + + /// The name of a driver to manage the storage for the images and the + /// container’s writable layer. The default is `devicemapper`. + /// + #[serde()] + #[structable(optional)] + docker_storage_driver: Option, + + /// The size in GB for the local storage on each server for the Docker + /// daemon to cache the images and host the containers. Cinder volumes + /// provide the storage. The default is 25 GB. For the `devicemapper` + /// storage driver, the minimum value is 3GB. For the `overlay` storage + /// driver, the minimum value is 1GB. + /// + #[serde()] + #[structable(optional)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional)] + driver: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the external internet for the cluster. This network must be an external + /// network, i.e. its attribute `router:external` must be `True`. The + /// servers in the cluster will be connected to a private network and + /// Magnum will create a router between this private network and the + /// external network. This will allow the servers to download images, + /// access discovery service, etc, and the containers to install packages, + /// etc. In the opposite direction, floating IPs will be allocated from the + /// external network to provide access from the external internet to + /// servers and the container services hosted in the cluster. + /// + #[serde()] + #[structable(optional)] + external_network_id: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the internal network for the cluster. + /// + #[serde()] + #[structable(optional)] + fixed_network: Option, + + /// Fixed subnet that are using to allocate network address for nodes in + /// cluster. + /// + #[serde()] + #[structable(optional)] + fixed_subnet: Option, + + /// The nova flavor ID or name for booting the node servers. The default is + /// `m1.small`. + /// + #[serde()] + #[structable(optional)] + flavor_id: Option, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. + /// + #[serde()] + #[structable(optional)] + floating_ip_enabled: Option, + + /// Indicates whether the ClusterTemplate is hidden or not, the default + /// value is false. + /// + #[serde()] + #[structable(optional)] + hidden: Option, + + /// The IP address for a proxy to use when direct http access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[serde()] + #[structable(optional)] + http_proxy: Option, + + /// The IP address for a proxy to use when direct https access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[serde()] + #[structable(optional)] + https_proxy: Option, + + /// The name or UUID of the base image in Glance to boot the servers for + /// the cluster. The image must have the attribute `os_distro` defined as + /// appropriate for the cluster driver. + /// + #[serde()] + #[structable()] + image_id: String, + + /// The URL pointing to users’s own private insecure docker registry to + /// deploy and run docker containers. + /// + #[serde()] + #[structable(optional)] + insecure_registry: Option, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[serde()] + #[structable(optional)] + keypair_id: Option, + + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + #[serde()] + #[structable(optional, pretty)] + labels: Option, + + /// Links to the resources in question. + /// + #[serde()] + #[structable(optional, pretty)] + links: Option, + + /// The flavor of the master node for this cluster template. + /// + #[serde()] + #[structable(optional)] + master_flavor_id: Option, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[serde()] + #[structable(optional)] + master_lb_enabled: Option, + + /// Name of the resource. + /// + #[serde()] + #[structable(optional)] + name: Option, + + /// The name of a network driver for providing the networks for the + /// containers. Note that this is different and separate from the Neutron + /// network for the cluster. The operation and networking model are + /// specific to the particular driver. + /// + #[serde()] + #[structable(optional)] + network_driver: Option, + + /// When a proxy server is used, some sites should not go through the proxy + /// and should be accessed normally. In this case, users can specify these + /// sites as a comma separated list of IPs. The default is `None`. + /// + #[serde()] + #[structable(optional)] + no_proxy: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + /// Access to a cluster template is normally limited to the admin, owner or + /// users within the same tenant as the owners. Setting this flag makes the + /// cluster template public and accessible by other users. The default is + /// not public. + /// + #[serde()] + #[structable(optional)] + public: Option, + + /// Docker images by default are pulled from the public Docker registry, + /// but in some cases, users may want to use a private registry. This + /// option provides an alternative registry based on the Registry V2: + /// Magnum will create a local registry in the cluster backed by swift to + /// host the images. The default is to use the public registry. + /// + #[serde()] + #[structable(optional)] + registry_enabled: Option, + + /// The servers in the cluster can be `vm` or `baremetal`. This parameter + /// selects the type of server to create for the cluster. The default is + /// `vm`. + /// + #[serde()] + #[structable(optional)] + server_type: Option, + + /// Administrator tags for the cluster template. + /// + #[serde()] + #[structable(optional)] + tags: Option, + + /// Transport Layer Security (TLS) is normally enabled to secure the + /// cluster. In some cases, users may want to disable TLS in the cluster, + /// for instance during development or to troubleshoot certain problems. + /// Specifying this parameter will disable TLS so that users can access the + /// COE endpoints without a certificate. The default is TLS enabled. + /// + #[serde()] + #[structable(optional)] + tls_disabled: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + user_id: Option, + + /// The UUID of the cluster template. + /// + #[serde()] + #[structable(optional)] + uuid: Option, + + /// The name of a volume driver for managing the persistent storage for the + /// containers. The functionality supported are specific to the driver. + /// + #[serde()] + #[structable(optional)] + volume_driver: Option, +} + +impl ClustertemplateCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Clustertemplate"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.apiserver_port data + if let Some(arg) = &self.apiserver_port { + ep_builder.apiserver_port(*arg); + } + + // Set Request.cluster_distro data + if let Some(arg) = &self.cluster_distro { + ep_builder.cluster_distro(arg); + } + + // Set Request.coe data + if let Some(arg) = &self.coe { + let tmp = match arg { + Coe::Kubernetes => create::Coe::Kubernetes, + }; + ep_builder.coe(tmp); + } + + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.dns_nameserver data + if let Some(arg) = &self.dns_nameserver { + ep_builder.dns_nameserver(arg); + } + + // Set Request.docker_storage_driver data + if let Some(arg) = &self.docker_storage_driver { + ep_builder.docker_storage_driver(arg); + } + + // Set Request.docker_volume_size data + if let Some(arg) = &self.docker_volume_size { + ep_builder.docker_volume_size(*arg); + } + + // Set Request.driver data + if let Some(arg) = &self.driver { + ep_builder.driver(arg); + } + + // Set Request.external_network_id data + if let Some(arg) = &self.external_network_id { + ep_builder.external_network_id(arg); + } + + // Set Request.fixed_network data + if let Some(arg) = &self.fixed_network { + ep_builder.fixed_network(arg); + } + + // Set Request.fixed_subnet data + if let Some(arg) = &self.fixed_subnet { + ep_builder.fixed_subnet(arg); + } + + // Set Request.flavor_id data + if let Some(arg) = &self.flavor_id { + ep_builder.flavor_id(arg); + } + + // Set Request.floating_ip_enabled data + if let Some(arg) = &self.floating_ip_enabled { + ep_builder.floating_ip_enabled(arg); + } + + // Set Request.hidden data + if let Some(arg) = &self.hidden { + ep_builder.hidden(arg); + } + + // Set Request.http_proxy data + if let Some(arg) = &self.http_proxy { + ep_builder.http_proxy(arg); + } + + // Set Request.https_proxy data + if let Some(arg) = &self.https_proxy { + ep_builder.https_proxy(arg); + } + + // Set Request.image_id data + ep_builder.image_id(&self.image_id); + + // Set Request.insecure_registry data + if let Some(arg) = &self.insecure_registry { + ep_builder.insecure_registry(arg); + } + + // Set Request.keypair_id data + if let Some(arg) = &self.keypair_id { + ep_builder.keypair_id(arg); + } + + // Set Request.labels data + if let Some(arg) = &self.labels { + ep_builder.labels(arg.iter().cloned()); + } + + // Set Request.links data + if let Some(arg) = &self.links { + let links_builder: Vec = arg + .iter() + .flat_map(|v| serde_json::from_value::(v.to_owned())) + .collect::>(); + ep_builder.links(links_builder); + } + + // Set Request.master_flavor_id data + if let Some(arg) = &self.master_flavor_id { + ep_builder.master_flavor_id(arg); + } + + // Set Request.master_lb_enabled data + if let Some(arg) = &self.master_lb_enabled { + ep_builder.master_lb_enabled(arg); + } + + // Set Request.name data + if let Some(arg) = &self.name { + ep_builder.name(arg); + } + + // Set Request.network_driver data + if let Some(arg) = &self.network_driver { + ep_builder.network_driver(arg); + } + + // Set Request.no_proxy data + if let Some(arg) = &self.no_proxy { + ep_builder.no_proxy(arg); + } + + // Set Request.project_id data + if let Some(arg) = &self.project_id { + ep_builder.project_id(arg); + } + + // Set Request.public data + if let Some(arg) = &self.public { + ep_builder.public(arg); + } + + // Set Request.registry_enabled data + if let Some(arg) = &self.registry_enabled { + ep_builder.registry_enabled(arg); + } + + // Set Request.server_type data + if let Some(arg) = &self.server_type { + let tmp = match arg { + ServerType::Bm => create::ServerType::Bm, + ServerType::Vm => create::ServerType::Vm, + }; + ep_builder.server_type(tmp); + } + + // Set Request.tags data + if let Some(arg) = &self.tags { + ep_builder.tags(arg); + } + + // Set Request.tls_disabled data + if let Some(arg) = &self.tls_disabled { + ep_builder.tls_disabled(arg); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + // Set Request.user_id data + if let Some(arg) = &self.user_id { + ep_builder.user_id(arg); + } + + // Set Request.uuid data + if let Some(arg) = &self.uuid { + ep_builder.uuid(arg); + } + + // Set Request.volume_driver data + if let Some(arg) = &self.volume_driver { + ep_builder.volume_driver(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/delete.rs b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/delete.rs new file mode 100644 index 000000000..513603c3b --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/delete.rs @@ -0,0 +1,101 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete Clustertemplate command +//! +//! Wraps invoking of the `v1/clustertemplates/{clustertemplate_id}` with `DELETE` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use bytes::Bytes; +use http::Response; +use openstack_sdk::api::container_infrastructure_management::v1::clustertemplate::delete; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete a cluster template. +/// +#[derive(Args)] +#[command(about = "Delete a cluster template")] +pub struct ClustertemplateCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// clustertemplate_id parameter for + /// /v1/clustertemplates/{clustertemplate_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Clustertemplate response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl ClustertemplateCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete Clustertemplate"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = delete::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let _rsp: Response = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/list.rs b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/list.rs new file mode 100644 index 000000000..160101fb6 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/list.rs @@ -0,0 +1,359 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List Clustertemplates command +//! +//! Wraps invoking of the `v1/clustertemplates` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::clustertemplate::list; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// List all available cluster templates in Magnum. +/// +#[derive(Args)] +#[command(about = "List all cluster templates")] +pub struct ClustertemplatesCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Clustertemplates response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The exposed port of COE API server. + /// + #[serde()] + #[structable(optional, wide)] + apiserver_port: Option, + + /// Display the attribute `os_distro` defined as appropriate metadata in + /// image for the cluster driver. + /// + #[serde()] + #[structable(optional, wide)] + cluster_distro: Option, + + /// Specify the Container Orchestration Engine to use. Supported COEs + /// include `kubernetes`. If your environment has additional cluster + /// drivers installed, refer to the cluster driver documentation for the + /// new COE names. + /// + #[serde()] + #[structable(optional, wide)] + coe: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + /// The DNS nameserver for the servers and containers in the cluster to + /// use. This is configured in the private Neutron network for the cluster. + /// The default is `8.8.8.8`. + /// + #[serde()] + #[structable(optional, wide)] + dns_nameserver: Option, + + /// The name of a driver to manage the storage for the images and the + /// container’s writable layer. The default is `devicemapper`. + /// + #[serde()] + #[structable(optional)] + docker_storage_driver: Option, + + /// The size in GB for the local storage on each server for the Docker + /// daemon to cache the images and host the containers. Cinder volumes + /// provide the storage. The default is 25 GB. For the `devicemapper` + /// storage driver, the minimum value is 3GB. For the `overlay` storage + /// driver, the minimum value is 1GB. + /// + #[serde()] + #[structable(optional, wide)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional)] + driver: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the external internet for the cluster. This network must be an external + /// network, i.e. its attribute `router:external` must be `True`. The + /// servers in the cluster will be connected to a private network and + /// Magnum will create a router between this private network and the + /// external network. This will allow the servers to download images, + /// access discovery service, etc, and the containers to install packages, + /// etc. In the opposite direction, floating IPs will be allocated from the + /// external network to provide access from the external internet to + /// servers and the container services hosted in the cluster. + /// + #[serde()] + #[structable(optional, wide)] + external_network_id: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the internal network for the cluster. + /// + #[serde()] + #[structable(optional, wide)] + fixed_network: Option, + + /// Fixed subnet that are using to allocate network address for nodes in + /// cluster. + /// + #[serde()] + #[structable(optional, wide)] + fixed_subnet: Option, + + /// The nova flavor ID or name for booting the node servers. The default is + /// `m1.small`. + /// + #[serde()] + #[structable(optional, wide)] + flavor_id: Option, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. + /// + #[serde()] + #[structable(optional)] + floating_ip_enabled: Option, + + /// Indicates whether the ClusterTemplate is hidden or not, the default + /// value is false. + /// + #[serde()] + #[structable(optional)] + hidden: Option, + + /// The IP address for a proxy to use when direct http access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[serde()] + #[structable(optional, wide)] + http_proxy: Option, + + /// The IP address for a proxy to use when direct https access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[serde()] + #[structable(optional, wide)] + https_proxy: Option, + + /// The name or UUID of the base image in Glance to boot the servers for + /// the cluster. The image must have the attribute `os_distro` defined as + /// appropriate for the cluster driver. + /// + #[serde()] + #[structable(wide)] + image_id: String, + + /// The URL pointing to users’s own private insecure docker registry to + /// deploy and run docker containers. + /// + #[serde()] + #[structable(optional, wide)] + insecure_registry: Option, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[serde()] + #[structable(optional, wide)] + keypair_id: Option, + + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + #[serde()] + #[structable(optional, pretty, wide)] + labels: Option, + + /// The flavor of the master node for this cluster template. + /// + #[serde()] + #[structable(optional, wide)] + master_flavor_id: Option, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[serde()] + #[structable(optional)] + master_lb_enabled: Option, + + /// Name of the resource. + /// + #[serde()] + #[structable(optional)] + name: Option, + + /// The name of a network driver for providing the networks for the + /// containers. Note that this is different and separate from the Neutron + /// network for the cluster. The operation and networking model are + /// specific to the particular driver. + /// + #[serde()] + #[structable(optional, wide)] + network_driver: Option, + + /// When a proxy server is used, some sites should not go through the proxy + /// and should be accessed normally. In this case, users can specify these + /// sites as a comma separated list of IPs. The default is `None`. + /// + #[serde()] + #[structable(optional, wide)] + no_proxy: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + /// Access to a cluster template is normally limited to the admin, owner or + /// users within the same tenant as the owners. Setting this flag makes the + /// cluster template public and accessible by other users. The default is + /// not public. + /// + #[serde()] + #[structable(optional, wide)] + public: Option, + + /// Docker images by default are pulled from the public Docker registry, + /// but in some cases, users may want to use a private registry. This + /// option provides an alternative registry based on the Registry V2: + /// Magnum will create a local registry in the cluster backed by swift to + /// host the images. The default is to use the public registry. + /// + #[serde()] + #[structable(optional, wide)] + registry_enabled: Option, + + /// The servers in the cluster can be `vm` or `baremetal`. This parameter + /// selects the type of server to create for the cluster. The default is + /// `vm`. + /// + #[serde()] + #[structable(optional, wide)] + server_type: Option, + + /// Administrator tags for the cluster template. + /// + #[serde()] + #[structable(optional)] + tags: Option, + + /// Transport Layer Security (TLS) is normally enabled to secure the + /// cluster. In some cases, users may want to disable TLS in the cluster, + /// for instance during development or to troubleshoot certain problems. + /// Specifying this parameter will disable TLS so that users can access the + /// COE endpoints without a certificate. The default is TLS enabled. + /// + #[serde()] + #[structable(optional, wide)] + tls_disabled: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + user_id: Option, + + /// The UUID of the cluster template. + /// + #[serde()] + #[structable(optional)] + uuid: Option, + + /// The name of a volume driver for managing the persistent storage for the + /// containers. The functionality supported are specific to the driver. + /// + #[serde()] + #[structable(optional, wide)] + volume_driver: Option, +} + +impl ClustertemplatesCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Clustertemplates"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/show.rs b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/show.rs new file mode 100644 index 000000000..b642ad05f --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/clustertemplate/show.rs @@ -0,0 +1,375 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show Clustertemplate command +//! +//! Wraps invoking of the `v1/clustertemplates/{clustertemplate_id}` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::clustertemplate::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Get all information of a cluster template in Magnum. +/// +#[derive(Args)] +#[command(about = "Show details of a cluster template")] +pub struct ClustertemplateCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// clustertemplate_id parameter for + /// /v1/clustertemplates/{clustertemplate_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Clustertemplate response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The exposed port of COE API server. + /// + #[serde()] + #[structable(optional)] + apiserver_port: Option, + + /// Display the attribute `os_distro` defined as appropriate metadata in + /// image for the cluster driver. + /// + #[serde()] + #[structable(optional)] + cluster_distro: Option, + + /// Specify the Container Orchestration Engine to use. Supported COEs + /// include `kubernetes`. If your environment has additional cluster + /// drivers installed, refer to the cluster driver documentation for the + /// new COE names. + /// + #[serde()] + #[structable(optional)] + coe: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + /// The DNS nameserver for the servers and containers in the cluster to + /// use. This is configured in the private Neutron network for the cluster. + /// The default is `8.8.8.8`. + /// + #[serde()] + #[structable(optional)] + dns_nameserver: Option, + + /// The name of a driver to manage the storage for the images and the + /// container’s writable layer. The default is `devicemapper`. + /// + #[serde()] + #[structable(optional)] + docker_storage_driver: Option, + + /// The size in GB for the local storage on each server for the Docker + /// daemon to cache the images and host the containers. Cinder volumes + /// provide the storage. The default is 25 GB. For the `devicemapper` + /// storage driver, the minimum value is 3GB. For the `overlay` storage + /// driver, the minimum value is 1GB. + /// + #[serde()] + #[structable(optional)] + docker_volume_size: Option, + + #[serde()] + #[structable(optional)] + driver: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the external internet for the cluster. This network must be an external + /// network, i.e. its attribute `router:external` must be `True`. The + /// servers in the cluster will be connected to a private network and + /// Magnum will create a router between this private network and the + /// external network. This will allow the servers to download images, + /// access discovery service, etc, and the containers to install packages, + /// etc. In the opposite direction, floating IPs will be allocated from the + /// external network to provide access from the external internet to + /// servers and the container services hosted in the cluster. + /// + #[serde()] + #[structable(optional)] + external_network_id: Option, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the internal network for the cluster. + /// + #[serde()] + #[structable(optional)] + fixed_network: Option, + + /// Fixed subnet that are using to allocate network address for nodes in + /// cluster. + /// + #[serde()] + #[structable(optional)] + fixed_subnet: Option, + + /// The nova flavor ID or name for booting the node servers. The default is + /// `m1.small`. + /// + #[serde()] + #[structable(optional)] + flavor_id: Option, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. + /// + #[serde()] + #[structable(optional)] + floating_ip_enabled: Option, + + /// Indicates whether the ClusterTemplate is hidden or not, the default + /// value is false. + /// + #[serde()] + #[structable(optional)] + hidden: Option, + + /// The IP address for a proxy to use when direct http access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[serde()] + #[structable(optional)] + http_proxy: Option, + + /// The IP address for a proxy to use when direct https access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[serde()] + #[structable(optional)] + https_proxy: Option, + + /// The name or UUID of the base image in Glance to boot the servers for + /// the cluster. The image must have the attribute `os_distro` defined as + /// appropriate for the cluster driver. + /// + #[serde()] + #[structable()] + image_id: String, + + /// The URL pointing to users’s own private insecure docker registry to + /// deploy and run docker containers. + /// + #[serde()] + #[structable(optional)] + insecure_registry: Option, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[serde()] + #[structable(optional)] + keypair_id: Option, + + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + #[serde()] + #[structable(optional, pretty)] + labels: Option, + + /// Links to the resources in question. + /// + #[serde()] + #[structable(optional, pretty)] + links: Option, + + /// The flavor of the master node for this cluster template. + /// + #[serde()] + #[structable(optional)] + master_flavor_id: Option, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[serde()] + #[structable(optional)] + master_lb_enabled: Option, + + /// Name of the resource. + /// + #[serde()] + #[structable(optional)] + name: Option, + + /// The name of a network driver for providing the networks for the + /// containers. Note that this is different and separate from the Neutron + /// network for the cluster. The operation and networking model are + /// specific to the particular driver. + /// + #[serde()] + #[structable(optional)] + network_driver: Option, + + /// When a proxy server is used, some sites should not go through the proxy + /// and should be accessed normally. In this case, users can specify these + /// sites as a comma separated list of IPs. The default is `None`. + /// + #[serde()] + #[structable(optional)] + no_proxy: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + /// Access to a cluster template is normally limited to the admin, owner or + /// users within the same tenant as the owners. Setting this flag makes the + /// cluster template public and accessible by other users. The default is + /// not public. + /// + #[serde()] + #[structable(optional)] + public: Option, + + /// Docker images by default are pulled from the public Docker registry, + /// but in some cases, users may want to use a private registry. This + /// option provides an alternative registry based on the Registry V2: + /// Magnum will create a local registry in the cluster backed by swift to + /// host the images. The default is to use the public registry. + /// + #[serde()] + #[structable(optional)] + registry_enabled: Option, + + /// The servers in the cluster can be `vm` or `baremetal`. This parameter + /// selects the type of server to create for the cluster. The default is + /// `vm`. + /// + #[serde()] + #[structable(optional)] + server_type: Option, + + /// Administrator tags for the cluster template. + /// + #[serde()] + #[structable(optional)] + tags: Option, + + /// Transport Layer Security (TLS) is normally enabled to secure the + /// cluster. In some cases, users may want to disable TLS in the cluster, + /// for instance during development or to troubleshoot certain problems. + /// Specifying this parameter will disable TLS so that users can access the + /// COE endpoints without a certificate. The default is TLS enabled. + /// + #[serde()] + #[structable(optional)] + tls_disabled: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + user_id: Option, + + /// The UUID of the cluster template. + /// + #[serde()] + #[structable(optional)] + uuid: Option, + + /// The name of a volume driver for managing the persistent storage for the + /// containers. The functionality supported are specific to the driver. + /// + #[serde()] + #[structable(optional)] + volume_driver: Option, +} + +impl ClustertemplateCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show Clustertemplate"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = get::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/federation/create.rs b/openstack_cli/src/container_infrastructure_management/v1/federation/create.rs new file mode 100644 index 000000000..30513b457 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/federation/create.rs @@ -0,0 +1,207 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Federation command +//! +//! Wraps invoking of the `v1/federations` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use crate::common::parse_json; +use crate::common::parse_key_val; +use clap::ValueEnum; +use openstack_sdk::api::container_infrastructure_management::v1::federation::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Create a new federation. +/// +/// | param federation: | | | --- | --- | | | a federation within the request +/// body. | +/// +#[derive(Args)] +pub struct FederationCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + #[arg(help_heading = "Body parameters", long)] + hostcluster_id: Option, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)] + links: Option>, + + #[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)] + member_ids: Option>, + + #[arg(help_heading = "Body parameters", long)] + name: Option, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + properties: Option>, + + #[arg(help_heading = "Body parameters", long)] + status: Option, + + #[arg(help_heading = "Body parameters", long)] + status_reason: Option, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, + + #[arg(help_heading = "Body parameters", long)] + uuid: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Status { + CreateComplete, + CreateFailed, + CreateInProgress, + DeleteComplete, + DeleteFailed, + DeleteInProgress, + UpdateComplete, + UpdateFailed, + UpdateInProgress, +} + +/// Federation response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable()] + uuid: String, +} + +impl FederationCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Federation"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.hostcluster_id data + if let Some(arg) = &self.hostcluster_id { + ep_builder.hostcluster_id(arg); + } + + // Set Request.links data + if let Some(arg) = &self.links { + let links_builder: Vec = arg + .iter() + .flat_map(|v| serde_json::from_value::(v.to_owned())) + .collect::>(); + ep_builder.links(links_builder); + } + + // Set Request.member_ids data + if let Some(arg) = &self.member_ids { + ep_builder.member_ids(arg.iter().map(Into::into).collect::>()); + } + + // Set Request.name data + if let Some(arg) = &self.name { + ep_builder.name(arg); + } + + // Set Request.properties data + if let Some(arg) = &self.properties { + ep_builder.properties(arg.iter().cloned()); + } + + // Set Request.status data + if let Some(arg) = &self.status { + let tmp = match arg { + Status::CreateComplete => create::Status::CreateComplete, + Status::CreateFailed => create::Status::CreateFailed, + Status::CreateInProgress => create::Status::CreateInProgress, + Status::DeleteComplete => create::Status::DeleteComplete, + Status::DeleteFailed => create::Status::DeleteFailed, + Status::DeleteInProgress => create::Status::DeleteInProgress, + Status::UpdateComplete => create::Status::UpdateComplete, + Status::UpdateFailed => create::Status::UpdateFailed, + Status::UpdateInProgress => create::Status::UpdateInProgress, + }; + ep_builder.status(tmp); + } + + // Set Request.status_reason data + if let Some(arg) = &self.status_reason { + ep_builder.status_reason(arg); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + // Set Request.uuid data + if let Some(arg) = &self.uuid { + ep_builder.uuid(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/federation/delete.rs b/openstack_cli/src/container_infrastructure_management/v1/federation/delete.rs new file mode 100644 index 000000000..6cd20fe5c --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/federation/delete.rs @@ -0,0 +1,102 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete Federation command +//! +//! Wraps invoking of the `v1/federations/{federation_id}` with `DELETE` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use bytes::Bytes; +use http::Response; +use openstack_sdk::api::container_infrastructure_management::v1::federation::delete; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete a federation. +/// +/// | param federation_ident: | | | --- | --- | | | UUID of federation or +/// logical name of the federation. | +/// +#[derive(Args)] +pub struct FederationCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// federation_id parameter for /v1/federations/{federation_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Federation response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl FederationCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete Federation"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = delete::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let _rsp: Response = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/federation/list.rs b/openstack_cli/src/container_infrastructure_management/v1/federation/list.rs new file mode 100644 index 000000000..e8581dbf4 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/federation/list.rs @@ -0,0 +1,131 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List Federations command +//! +//! Wraps invoking of the `v1/federations` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::federation::list; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Retrieve a list of federations. +/// +/// | | | | --- | --- | | param marker: | pagination marker for large data +/// sets. | | param limit: | maximum number of resources to return in a single +/// result. | | param sort_key: | column to sort results by. Default: id. | | +/// param sort_dir: | direction to sort. "asc" or "desc". Default: asc. | +/// +#[derive(Args)] +pub struct FederationsCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Federations response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + hostcluster_id: Option, + + #[serde()] + #[structable(optional, pretty)] + member_ids: Option, + + #[serde()] + #[structable(optional)] + name: Option, + + #[serde()] + #[structable(optional, pretty)] + properties: Option, + + #[serde()] + #[structable(optional)] + status: Option, + + #[serde()] + #[structable(optional)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + uuid: Option, +} + +impl FederationsCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Federations"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/federation/show.rs b/openstack_cli/src/container_infrastructure_management/v1/federation/show.rs new file mode 100644 index 000000000..85e1992ef --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/federation/show.rs @@ -0,0 +1,142 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show Federation command +//! +//! Wraps invoking of the `v1/federations/{federation_id}` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::federation::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Retrieve information about a given Federation. +/// +/// | param federation_ident: | | | --- | --- | | | UUID or logical name of the +/// Federation. | +/// +#[derive(Args)] +pub struct FederationCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// federation_id parameter for /v1/federations/{federation_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Federation response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + hostcluster_id: Option, + + #[serde()] + #[structable(optional, pretty)] + links: Option, + + #[serde()] + #[structable(optional, pretty)] + member_ids: Option, + + #[serde()] + #[structable(optional)] + name: Option, + + #[serde()] + #[structable(optional, pretty)] + properties: Option, + + #[serde()] + #[structable(optional)] + status: Option, + + #[serde()] + #[structable(optional)] + status_reason: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, + + #[serde()] + #[structable(optional)] + uuid: Option, +} + +impl FederationCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show Federation"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = get::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/mservice/list.rs b/openstack_cli/src/container_infrastructure_management/v1/mservice/list.rs new file mode 100644 index 000000000..fb5b1afb4 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/mservice/list.rs @@ -0,0 +1,176 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List Mservices command +//! +//! Wraps invoking of the `v1/mservices` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::mservice::list; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// Enables administrative users to list all Magnum services. +/// +/// Container infrastructure service information include service id, binary, +/// host, report count, creation time, last updated time, health status, and +/// the reason for disabling service. +/// +#[derive(Args)] +#[command(about = "List container infrastructure management services")] +pub struct MservicesCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Mservices response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The name of the binary form of the Magnum service. + /// + #[serde()] + #[structable(optional, wide)] + binary: Option, + + /// The date and time when the resource was created. + /// + /// The date and time stamp format is + /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): + /// + /// ```text + /// CCYY-MM-DDThh:mm:ss±hh:mm + /// + /// ``` + /// + /// For example, `2015-08-27T09:49:58-05:00`. + /// + /// The `±hh:mm` value, if included, is the time zone as an offset from + /// UTC. + /// + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional, wide)] + disabled: Option, + + /// The disable reason of the service, `null` if the service is enabled or + /// disabled without reason provided. + /// + #[serde()] + #[structable(optional, wide)] + disabled_reason: Option, + + /// The host for the service. + /// + #[serde()] + #[structable(optional, wide)] + host: Option, + + /// The ID of the Magnum service. + /// + #[serde()] + #[structable(optional)] + id: Option, + + /// The total number of report. + /// + #[serde()] + #[structable(optional, wide)] + report_count: Option, + + /// The current state of Magnum services. + /// + #[serde()] + #[structable(optional, status)] + state: Option, + + /// The date and time when the resource was updated. + /// + /// The date and time stamp format is + /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): + /// + /// ```text + /// CCYY-MM-DDThh:mm:ss±hh:mm + /// + /// ``` + /// + /// For example, `2015-08-27T09:49:58-05:00`. + /// + /// The `±hh:mm` value, if included, is the time zone as an offset from + /// UTC. In the previous example, the offset value is `-05:00`. + /// + /// If the `updated_at` date and time stamp is not set, its value is + /// `null`. + /// + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl MservicesCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Mservices"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/quota/create.rs b/openstack_cli/src/container_infrastructure_management/v1/quota/create.rs new file mode 100644 index 000000000..49bf12bf4 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/quota/create.rs @@ -0,0 +1,170 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create Quota command +//! +//! Wraps invoking of the `v1/quotas` with `POST` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use clap::ValueEnum; +use openstack_sdk::api::container_infrastructure_management::v1::quota::create; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// Create new quota for a project. +/// +#[derive(Args)] +#[command(about = "Set new quota")] +pub struct QuotaCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + created_at: Option, + + #[arg(help_heading = "Body parameters", long)] + hard_limit: Option, + + #[arg(help_heading = "Body parameters", long)] + id: Option, + + #[arg(help_heading = "Body parameters", long)] + project_id: Option, + + #[arg(help_heading = "Body parameters", long)] + resource: Option, + + #[arg(help_heading = "Body parameters", long)] + updated_at: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Resource { + Cluster, +} + +/// Quota response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + hard_limit: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + #[serde()] + #[structable(optional)] + resource: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl QuotaCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Quota"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.created_at data + if let Some(arg) = &self.created_at { + ep_builder.created_at(arg); + } + + // Set Request.hard_limit data + if let Some(arg) = &self.hard_limit { + ep_builder.hard_limit(*arg); + } + + // Set Request.id data + if let Some(arg) = &self.id { + ep_builder.id(*arg); + } + + // Set Request.project_id data + if let Some(arg) = &self.project_id { + ep_builder.project_id(arg); + } + + // Set Request.resource data + if let Some(arg) = &self.resource { + let tmp = match arg { + Resource::Cluster => create::Resource::Cluster, + }; + ep_builder.resource(tmp); + } + + // Set Request.updated_at data + if let Some(arg) = &self.updated_at { + ep_builder.updated_at(arg); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/quota/delete.rs b/openstack_cli/src/container_infrastructure_management/v1/quota/delete.rs new file mode 100644 index 000000000..e35fdc0c9 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/quota/delete.rs @@ -0,0 +1,102 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete Quota command +//! +//! Wraps invoking of the `v1/quotas/{quota_id}` with `DELETE` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use bytes::Bytes; +use http::Response; +use openstack_sdk::api::container_infrastructure_management::v1::quota::delete; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete Quota for a given project_id and resource. +/// +/// | param project_id: | | | --- | --- | | | project id. | | param resource: | +/// resource name. | +/// +#[derive(Args)] +pub struct QuotaCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// quota_id parameter for /v1/quotas/{quota_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Quota response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl QuotaCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete Quota"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = delete::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let _rsp: Response = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/quota/list.rs b/openstack_cli/src/container_infrastructure_management/v1/quota/list.rs new file mode 100644 index 000000000..c2580e8fa --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/quota/list.rs @@ -0,0 +1,114 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List Quotas command +//! +//! Wraps invoking of the `v1/quotas` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::quota::list; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// List all quotas in Magnum. +/// +#[derive(Args)] +#[command(about = "List all quotas")] +pub struct QuotasCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Quotas response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional, wide)] + hard_limit: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional, wide)] + project_id: Option, + + #[serde()] + #[structable(optional, wide)] + resource: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl QuotasCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Quotas"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/quota/show.rs b/openstack_cli/src/container_infrastructure_management/v1/quota/show.rs new file mode 100644 index 000000000..4b14c1e59 --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/quota/show.rs @@ -0,0 +1,125 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show Quota command +//! +//! Wraps invoking of the `v1/quotas/{quota_id}` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::quota::get; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// Retrieve Quota information for the given project_id. +/// +/// | | | | --- | --- | | param id: | project id. | | param resource: | +/// resource name. | +/// +#[derive(Args)] +pub struct QuotaCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// quota_id parameter for /v1/quotas/{quota_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Quota response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional)] + hard_limit: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional)] + project_id: Option, + + #[serde()] + #[structable(optional)] + resource: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl QuotaCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show Quota"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = get::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/stat/get.rs b/openstack_cli/src/container_infrastructure_management/v1/stat/get.rs new file mode 100644 index 000000000..4f0b77dbb --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/stat/get.rs @@ -0,0 +1,110 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Get Stat command +//! +//! Wraps invoking of the `v1/stats` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::stat::get; +use openstack_sdk::api::QueryAsync; +use structable_derive::StructTable; + +/// Show overall Magnum system stats. If the requester is non-admin user show +/// self stats. +/// +#[derive(Args)] +#[command(about = "Show overall stats")] +pub struct StatCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Stat response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// The number of clusters. + /// + #[serde()] + #[structable(optional)] + clusters: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + /// The total number of nodes including master nodes. + /// + #[serde()] + #[structable(optional)] + nodes: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl StatCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Get Stat"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = get::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/container_infrastructure_management/v1/version/get.rs b/openstack_cli/src/container_infrastructure_management/v1/version/get.rs new file mode 100644 index 000000000..522f9e05b --- /dev/null +++ b/openstack_cli/src/container_infrastructure_management/v1/version/get.rs @@ -0,0 +1,141 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Get Version command +//! +//! Wraps invoking of the `v1` with `GET` method + +use clap::Args; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use openstack_sdk::AsyncOpenStack; + +use crate::output::OutputProcessor; +use crate::Cli; +use crate::OpenStackCliError; +use crate::OutputConfig; +use crate::StructTable; + +use openstack_sdk::api::container_infrastructure_management::v1::version::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Command without description in OpenAPI +/// +#[derive(Args)] +pub struct VersionCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Version response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + #[serde()] + #[structable(optional, pretty)] + certificates: Option, + + #[serde()] + #[structable(optional, pretty)] + clusters: Option, + + #[serde()] + #[structable(optional, pretty)] + clustertemplates: Option, + + #[serde()] + #[structable(optional)] + created_at: Option, + + #[serde()] + #[structable(optional, pretty)] + federations: Option, + + #[serde()] + #[structable(optional)] + id: Option, + + #[serde()] + #[structable(optional, pretty)] + links: Option, + + #[serde()] + #[structable(optional, pretty)] + media_types: Option, + + #[serde()] + #[structable(optional, pretty)] + mservices: Option, + + #[serde()] + #[structable(optional, pretty)] + nodegroups: Option, + + #[serde()] + #[structable(optional, pretty)] + quotas: Option, + + #[serde()] + #[structable(optional, pretty)] + stats: Option, + + #[serde()] + #[structable(optional)] + updated_at: Option, +} + +impl VersionCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Get Version"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = get::Request::builder(); + + // Set path parameters + // Set query parameters + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/dns/v2/zone/share/list.rs b/openstack_cli/src/dns/v2/zone/share/list.rs index 1ef73f326..d79e15407 100644 --- a/openstack_cli/src/dns/v2/zone/share/list.rs +++ b/openstack_cli/src/dns/v2/zone/share/list.rs @@ -39,7 +39,6 @@ use openstack_sdk::api::find_by_name; use openstack_sdk::api::QueryAsync; use openstack_sdk::api::{paged, Pagination}; use serde_json::Value; -use std::fmt; use structable_derive::StructTable; use tracing::warn; @@ -114,28 +113,6 @@ struct ResponseData { #[structable(optional, pretty)] shared_zones: Option, } -/// `struct` response type -#[derive(Default, Clone, Deserialize, Serialize)] -struct ResponseLinks { - _self: Option, - zone: Option, -} - -impl fmt::Display for ResponseLinks { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let data = Vec::from([ - format!( - "_self={}", - self._self.clone().map_or(String::new(), |v| v.to_string()) - ), - format!( - "zone={}", - self.zone.clone().map_or(String::new(), |v| v.to_string()) - ), - ]); - write!(f, "{}", data.join(";")) - } -} impl SharesCommand { /// Perform command action diff --git a/openstack_cli/tests/container_infrastructure_management/v1/certificate/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/certificate/create_autogen.rs new file mode 100644 index 000000000..ca936b7e6 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/certificate/create_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("certificate") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/certificate/show_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/certificate/show_autogen.rs new file mode 100644 index 000000000..00bdec215 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/certificate/show_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("certificate") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/action/resize/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/action/resize/create_autogen.rs new file mode 100644 index 000000000..4e748794a --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/action/resize/create_autogen.rs @@ -0,0 +1,34 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("action") + .arg("resize") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/action/upgrade/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/action/upgrade/create_autogen.rs new file mode 100644 index 000000000..9e384b30d --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/action/upgrade/create_autogen.rs @@ -0,0 +1,34 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("action") + .arg("upgrade") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/create_autogen.rs new file mode 100644 index 000000000..8f7cb27a6 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/create_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/delete_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/delete_autogen.rs new file mode 100644 index 000000000..0f6dcb356 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/delete_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/list_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/list_autogen.rs new file mode 100644 index 000000000..d82319b9c --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/list_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/create_autogen.rs new file mode 100644 index 000000000..b4ea7531f --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/create_autogen.rs @@ -0,0 +1,33 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("nodegroup") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/delete_all_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/delete_all_autogen.rs new file mode 100644 index 000000000..d43a25bf6 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/delete_all_autogen.rs @@ -0,0 +1,33 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("nodegroup") + .arg("delete-all") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/delete_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/delete_autogen.rs new file mode 100644 index 000000000..479d0d765 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/delete_autogen.rs @@ -0,0 +1,33 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("nodegroup") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/list_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/list_autogen.rs new file mode 100644 index 000000000..a09b47155 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/list_autogen.rs @@ -0,0 +1,33 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("nodegroup") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/set_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/set_autogen.rs new file mode 100644 index 000000000..c0a53a545 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/set_autogen.rs @@ -0,0 +1,33 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("nodegroup") + .arg("set") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/show_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/show_autogen.rs new file mode 100644 index 000000000..5623b5c83 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/nodegroup/show_autogen.rs @@ -0,0 +1,33 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("nodegroup") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/set_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/set_autogen.rs new file mode 100644 index 000000000..4b4e1b419 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/set_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("set") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/cluster/show_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/cluster/show_autogen.rs new file mode 100644 index 000000000..c4d552780 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/cluster/show_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("cluster") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/create_autogen.rs new file mode 100644 index 000000000..7e23f0e22 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/create_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("clustertemplate") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/delete_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/delete_autogen.rs new file mode 100644 index 000000000..494a66d83 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/delete_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("clustertemplate") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/list_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/list_autogen.rs new file mode 100644 index 000000000..e0f786981 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/list_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("clustertemplate") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/show_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/show_autogen.rs new file mode 100644 index 000000000..6b0b0795f --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/clustertemplate/show_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("clustertemplate") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/federation/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/federation/create_autogen.rs new file mode 100644 index 000000000..a32e3abfe --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/federation/create_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("federation") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/federation/delete_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/federation/delete_autogen.rs new file mode 100644 index 000000000..4d957f731 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/federation/delete_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("federation") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/federation/list_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/federation/list_autogen.rs new file mode 100644 index 000000000..a168a6845 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/federation/list_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("federation") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/federation/show_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/federation/show_autogen.rs new file mode 100644 index 000000000..07c99bfee --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/federation/show_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("federation") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/mservice/list_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/mservice/list_autogen.rs new file mode 100644 index 000000000..76bf919f7 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/mservice/list_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("mservice") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/quota/create_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/quota/create_autogen.rs new file mode 100644 index 000000000..9603ce1b5 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/quota/create_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("quota") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/quota/delete_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/quota/delete_autogen.rs new file mode 100644 index 000000000..33c2691be --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/quota/delete_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("quota") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/quota/list_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/quota/list_autogen.rs new file mode 100644 index 000000000..996bdc480 --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/quota/list_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("quota") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/quota/show_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/quota/show_autogen.rs new file mode 100644 index 000000000..92b3264ba --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/quota/show_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("quota") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/stat/get_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/stat/get_autogen.rs new file mode 100644 index 000000000..d52b1963d --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/stat/get_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("stat") + .arg("get") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/container_infrastructure_management/v1/version/get_autogen.rs b/openstack_cli/tests/container_infrastructure_management/v1/version/get_autogen.rs new file mode 100644 index 000000000..05b7d9e8e --- /dev/null +++ b/openstack_cli/tests/container_infrastructure_management/v1/version/get_autogen.rs @@ -0,0 +1,32 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("container-infrastructure-management") + .arg("version") + .arg("get") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1.rs b/openstack_sdk/src/api/container_infrastructure_management/v1.rs index 0abb76f01..eaac0bfaf 100644 --- a/openstack_sdk/src/api/container_infrastructure_management/v1.rs +++ b/openstack_sdk/src/api/container_infrastructure_management/v1.rs @@ -11,3 +11,16 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `Container_infrastructure_management` Service bindings +pub mod certificate; +pub mod cluster; +pub mod clustertemplate; +pub mod federation; +pub mod mservice; +pub mod quota; +pub mod stat; +pub mod version; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/certificate.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/certificate.rs new file mode 100644 index 000000000..4fb295e8d --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/certificate.rs @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/certificates/{id}` REST operations of container_infrastructure_management +pub mod create; +pub mod get; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/create.rs new file mode 100644 index 000000000..6bb014b46 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/create.rs @@ -0,0 +1,248 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Sign a new certificate by the CA. +//! +//! | param certificate: | | | --- | --- | | | a certificate within the request +//! body. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A link representation. +/// +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Links<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) href: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rel: Option>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _type: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) ca_cert_type: Option>, + + #[builder(default, setter(into))] + pub(crate) cluster_uuid: Option>, + + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[builder(default, setter(into))] + pub(crate) csr: Option>, + + #[builder(default, setter(into))] + pub(crate) links: Option>>, + + #[builder(default, setter(into))] + pub(crate) pem: Option>, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Certificate. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "certificates".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.cluster_uuid { + params.push("cluster_uuid", serde_json::to_value(val)?); + } + if let Some(val) = &self.links { + params.push("links", serde_json::to_value(val)?); + } + if let Some(val) = &self.csr { + params.push("csr", serde_json::to_value(val)?); + } + if let Some(val) = &self.pem { + params.push("pem", serde_json::to_value(val)?); + } + if let Some(val) = &self.ca_cert_type { + params.push("ca_cert_type", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/certificates".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/certificates".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/get.rs new file mode 100644 index 000000000..9cb295cbb --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/get.rs @@ -0,0 +1,175 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show CA certificate details that are associated with the created cluster +//! based on the given CA certificate type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// certificate_id parameter for /v1/certificates/{certificate_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Certificate. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("certificates/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/certificates/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/certificates/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster.rs new file mode 100644 index 000000000..61a6ecc27 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster.rs @@ -0,0 +1,25 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/clusters` REST operations of container_infrastructure_management +pub mod action; +pub mod create; +pub mod delete; +pub mod get; +pub mod list; +pub mod nodegroup; +pub mod set; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action.rs new file mode 100644 index 000000000..8d7c0cdd4 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action.rs @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/federations` REST operations of container_infrastructure_management +pub mod resize; +pub mod upgrade; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize.rs new file mode 100644 index 000000000..08c656ed9 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize.rs @@ -0,0 +1,19 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/clusters/actions/resize` REST operations of container_infrastructure_management +pub mod create; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize/create.rs new file mode 100644 index 000000000..48cf6f127 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize/create.rs @@ -0,0 +1,211 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[builder()] + pub(crate) node_count: i32, + + #[builder(default, setter(into))] + pub(crate) nodegroup: Option>, + + #[builder(default, setter(into))] + pub(crate) nodes_to_remove: Option>>, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Resize. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "clusters/actions/resize".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("node_count", serde_json::to_value(self.node_count)?); + if let Some(val) = &self.nodes_to_remove { + params.push("nodes_to_remove", serde_json::to_value(val)?); + } + if let Some(val) = &self.nodegroup { + params.push("nodegroup", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .node_count(123) + .build() + .unwrap() + .service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .node_count(123) + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters/actions/resize".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().node_count(123).build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters/actions/resize".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .node_count(123) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade.rs new file mode 100644 index 000000000..01ba40395 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade.rs @@ -0,0 +1,19 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/clusters/actions/upgrade` REST operations of container_infrastructure_management +pub mod create; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade/create.rs new file mode 100644 index 000000000..aacfeac72 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade/create.rs @@ -0,0 +1,203 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) cluster_template: Option>, + + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[builder(default)] + pub(crate) max_batch_size: Option, + + #[builder(default, setter(into))] + pub(crate) nodegroup: Option>, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Upgrade. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "clusters/actions/upgrade".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.max_batch_size { + params.push("max_batch_size", serde_json::to_value(val)?); + } + if let Some(val) = &self.nodegroup { + params.push("nodegroup", serde_json::to_value(val)?); + } + if let Some(val) = &self.cluster_template { + params.push("cluster_template", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters/actions/upgrade".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters/actions/upgrade".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/create.rs new file mode 100644 index 000000000..73d72bd11 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/create.rs @@ -0,0 +1,634 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create new cluster based on cluster template. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A link representation. +/// +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Links<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) href: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rel: Option>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _type: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Status { + #[serde(rename = "ADOPT_COMPLETE")] + AdoptComplete, + #[serde(rename = "CHECK_COMPLETE")] + CheckComplete, + #[serde(rename = "CREATE_COMPLETE")] + CreateComplete, + #[serde(rename = "CREATE_FAILED")] + CreateFailed, + #[serde(rename = "CREATE_IN_PROGRESS")] + CreateInProgress, + #[serde(rename = "DELETE_COMPLETE")] + DeleteComplete, + #[serde(rename = "DELETE_FAILED")] + DeleteFailed, + #[serde(rename = "DELETE_IN_PROGRESS")] + DeleteInProgress, + #[serde(rename = "RESTORE_COMPLETE")] + RestoreComplete, + #[serde(rename = "RESUME_COMPLETE")] + ResumeComplete, + #[serde(rename = "RESUME_FAILED")] + ResumeFailed, + #[serde(rename = "ROLLBACK_COMPLETE")] + RollbackComplete, + #[serde(rename = "ROLLBACK_FAILED")] + RollbackFailed, + #[serde(rename = "ROLLBACK_IN_PROGRESS")] + RollbackInProgress, + #[serde(rename = "SNAPSHOT_COMPLETE")] + SnapshotComplete, + #[serde(rename = "UPDATE_COMPLETE")] + UpdateComplete, + #[serde(rename = "UPDATE_FAILED")] + UpdateFailed, + #[serde(rename = "UPDATE_IN_PROGRESS")] + UpdateInProgress, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HealthStatus { + #[serde(rename = "HEALTHY")] + Healthy, + #[serde(rename = "UNHEALTHY")] + Unhealthy, + #[serde(rename = "UNKNOWN")] + Unknown, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) api_address: Option>, + + /// The UUID of the cluster template. + /// + #[builder(setter(into))] + pub(crate) cluster_template_id: Cow<'a, str>, + + #[builder(default, setter(into))] + pub(crate) coe_version: Option>, + + #[builder(default, setter(into))] + pub(crate) container_version: Option>, + + /// The timeout for cluster creation in minutes. The value expected is a + /// positive integer and the default is 60 minutes. If the timeout is + /// reached during cluster creation process, the operation will be aborted + /// and the cluster status will be set to `CREATE_FAILED`. + /// + #[builder(default)] + pub(crate) create_timeout: Option, + + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + /// The custom discovery url for node discovery. This is used by the COE to + /// discover the servers that have been created to host the containers. The + /// actual discovery mechanism varies with the COE. In some cases, Magnum + /// fills in the server info in the discovery service. In other cases, if + /// the `discovery_url` is not specified, Magnum will use the public + /// discovery service at: + /// + /// ```text + /// https://discovery.etcd.io + /// + /// ``` + /// + /// In this case, Magnum will generate a unique url here for each uster and + /// store the info for the servers. + /// + #[builder(default, setter(into))] + pub(crate) discovery_url: Option>, + + #[builder(default)] + pub(crate) docker_volume_size: Option, + + #[builder(default, private, setter(name = "_faults"))] + pub(crate) faults: Option, Cow<'a, str>>>, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the internal network for the cluster. + /// + #[builder(default, setter(into))] + pub(crate) fixed_network: Option>, + + /// Fixed subnet that are using to allocate network address for nodes in + /// cluster. + /// + #[builder(default, setter(into))] + pub(crate) fixed_subnet: Option>, + + /// The nova flavor ID or name for booting the node servers. The default is + /// `m1.small`. + /// + #[builder(default, setter(into))] + pub(crate) flavor_id: Option>, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. If + /// it’s not set, the value of floating_ip_enabled in template will be + /// used. + /// + #[builder(default, setter(into))] + pub(crate) floating_ip_enabled: Option>, + + #[builder(default)] + pub(crate) health_status: Option, + + #[builder(default, private, setter(name = "_health_status_reason"))] + pub(crate) health_status_reason: Option, Cow<'a, str>>>, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[builder(default, setter(into))] + pub(crate) keypair: Option>, + + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + #[builder(default, private, setter(name = "_labels"))] + pub(crate) labels: Option, Cow<'a, str>>>, + + #[builder(default, private, setter(name = "_labels_added"))] + pub(crate) labels_added: Option, Cow<'a, str>>>, + + #[builder(default, private, setter(name = "_labels_overridden"))] + pub(crate) labels_overridden: Option, Cow<'a, str>>>, + + #[builder(default, private, setter(name = "_labels_skipped"))] + pub(crate) labels_skipped: Option, Cow<'a, str>>>, + + #[builder(default, setter(into))] + pub(crate) links: Option>>, + + #[builder(default, setter(into))] + pub(crate) master_addresses: Option>>, + + /// The number of servers that will serve as master for the cluster. The + /// default is 1. Set to more than 1 master to enable High Availability. If + /// the option `master-lb-enabled` is specified in the cluster template, + /// the master servers will be placed in a load balancer pool. + /// + #[builder(default)] + pub(crate) master_count: Option, + + /// The flavor of the master node for this cluster template. + /// + #[builder(default, setter(into))] + pub(crate) master_flavor_id: Option>, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[builder(default, setter(into))] + pub(crate) master_lb_enabled: Option>, + + #[builder(default, setter(into))] + pub(crate) merge_labels: Option>, + + /// Name of the resource. + /// + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[builder(default, setter(into))] + pub(crate) node_addresses: Option>>, + + /// The number of servers that will serve as node in the cluster. The + /// default is 1. + /// + #[builder(default)] + pub(crate) node_count: Option, + + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + #[builder(default, setter(into))] + pub(crate) stack_id: Option>, + + #[builder(default)] + pub(crate) status: Option, + + #[builder(default, setter(into))] + pub(crate) status_reason: Option>, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(default, setter(into))] + pub(crate) user_id: Option>, + + #[builder(default, setter(into))] + pub(crate) uuid: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + pub fn labels(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn health_status_reason(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.health_status_reason + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn faults(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.faults + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn labels_overridden(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels_overridden + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn labels_added(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels_added + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn labels_skipped(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels_skipped + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "clusters".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.uuid { + params.push("uuid", serde_json::to_value(val)?); + } + if let Some(val) = &self.name { + params.push("name", serde_json::to_value(val)?); + } + params.push( + "cluster_template_id", + serde_json::to_value(&self.cluster_template_id)?, + ); + if let Some(val) = &self.keypair { + params.push("keypair", serde_json::to_value(val)?); + } + if let Some(val) = &self.node_count { + params.push("node_count", serde_json::to_value(val)?); + } + if let Some(val) = &self.master_count { + params.push("master_count", serde_json::to_value(val)?); + } + if let Some(val) = &self.docker_volume_size { + params.push("docker_volume_size", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels { + params.push("labels", serde_json::to_value(val)?); + } + if let Some(val) = &self.master_flavor_id { + params.push("master_flavor_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.flavor_id { + params.push("flavor_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.create_timeout { + params.push("create_timeout", serde_json::to_value(val)?); + } + if let Some(val) = &self.links { + params.push("links", serde_json::to_value(val)?); + } + if let Some(val) = &self.stack_id { + params.push("stack_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.status { + params.push("status", serde_json::to_value(val)?); + } + if let Some(val) = &self.status_reason { + params.push("status_reason", serde_json::to_value(val)?); + } + if let Some(val) = &self.health_status { + params.push("health_status", serde_json::to_value(val)?); + } + if let Some(val) = &self.health_status_reason { + params.push("health_status_reason", serde_json::to_value(val)?); + } + if let Some(val) = &self.discovery_url { + params.push("discovery_url", serde_json::to_value(val)?); + } + if let Some(val) = &self.api_address { + params.push("api_address", serde_json::to_value(val)?); + } + if let Some(val) = &self.coe_version { + params.push("coe_version", serde_json::to_value(val)?); + } + if let Some(val) = &self.container_version { + params.push("container_version", serde_json::to_value(val)?); + } + if let Some(val) = &self.project_id { + params.push("project_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.user_id { + params.push("user_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.node_addresses { + params.push("node_addresses", serde_json::to_value(val)?); + } + if let Some(val) = &self.master_addresses { + params.push("master_addresses", serde_json::to_value(val)?); + } + if let Some(val) = &self.faults { + params.push("faults", serde_json::to_value(val)?); + } + if let Some(val) = &self.fixed_network { + params.push("fixed_network", serde_json::to_value(val)?); + } + if let Some(val) = &self.fixed_subnet { + params.push("fixed_subnet", serde_json::to_value(val)?); + } + if let Some(val) = &self.floating_ip_enabled { + params.push("floating_ip_enabled", serde_json::to_value(val)?); + } + if let Some(val) = &self.merge_labels { + params.push("merge_labels", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels_overridden { + params.push("labels_overridden", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels_added { + params.push("labels_added", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels_skipped { + params.push("labels_skipped", serde_json::to_value(val)?); + } + if let Some(val) = &self.master_lb_enabled { + params.push("master_lb_enabled", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .cluster_template_id("foo") + .build() + .unwrap() + .service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .cluster_template_id("foo") + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .cluster_template_id("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .cluster_template_id("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/delete.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/delete.rs new file mode 100644 index 000000000..be595da77 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/delete.rs @@ -0,0 +1,174 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete a cluster. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// cluster_id parameter for /v1/clusters/{cluster_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clusters/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/clusters/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/clusters/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/get.rs new file mode 100644 index 000000000..7f9fc388b --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/get.rs @@ -0,0 +1,174 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Get all information of a cluster in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// cluster_id parameter for /v1/clusters/{cluster_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clusters/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/clusters/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/clusters/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/list.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/list.rs new file mode 100644 index 000000000..97df449d3 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/list.rs @@ -0,0 +1,169 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List all clusters in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "clusters".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + Some("clusters".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "clusters" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clusters".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "clusters": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clusters".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "clusters": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup.rs new file mode 100644 index 000000000..6398dc2c0 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup.rs @@ -0,0 +1,25 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/clusters/nodegroups` REST operations of container_infrastructure_management +pub mod create; +pub mod delete; +pub mod delete_all; +pub mod find; +pub mod get; +pub mod list; +pub mod set; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/create.rs new file mode 100644 index 000000000..f1b4666d4 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/create.rs @@ -0,0 +1,459 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Retrieve a list of nodegroups. +//! +//! | param cluster_id: | | | --- | --- | | | the cluster id or name | | param +//! marker: | pagination marker for large data sets. | | param limit: | maximum +//! number of resources to return in a single result. | | param sort_key: | +//! column to sort results by. Default: id. | | param sort_dir: | direction to +//! sort. "asc" or "desc". Default: asc. | | param role: | list all nodegroups +//! with the specified role. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A link representation. +/// +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Links<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) href: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rel: Option>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _type: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Status { + #[serde(rename = "ADOPT_COMPLETE")] + AdoptComplete, + #[serde(rename = "CHECK_COMPLETE")] + CheckComplete, + #[serde(rename = "CREATE_COMPLETE")] + CreateComplete, + #[serde(rename = "CREATE_FAILED")] + CreateFailed, + #[serde(rename = "CREATE_IN_PROGRESS")] + CreateInProgress, + #[serde(rename = "DELETE_COMPLETE")] + DeleteComplete, + #[serde(rename = "DELETE_FAILED")] + DeleteFailed, + #[serde(rename = "DELETE_IN_PROGRESS")] + DeleteInProgress, + #[serde(rename = "RESTORE_COMPLETE")] + RestoreComplete, + #[serde(rename = "RESUME_COMPLETE")] + ResumeComplete, + #[serde(rename = "RESUME_FAILED")] + ResumeFailed, + #[serde(rename = "ROLLBACK_COMPLETE")] + RollbackComplete, + #[serde(rename = "ROLLBACK_FAILED")] + RollbackFailed, + #[serde(rename = "ROLLBACK_IN_PROGRESS")] + RollbackInProgress, + #[serde(rename = "SNAPSHOT_COMPLETE")] + SnapshotComplete, + #[serde(rename = "UPDATE_COMPLETE")] + UpdateComplete, + #[serde(rename = "UPDATE_FAILED")] + UpdateFailed, + #[serde(rename = "UPDATE_IN_PROGRESS")] + UpdateInProgress, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) cluster_id: Option>, + + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[builder(default)] + pub(crate) docker_volume_size: Option, + + #[builder(default, setter(into))] + pub(crate) flavor_id: Option>, + + #[builder(default)] + pub(crate) id: Option, + + #[builder(default, setter(into))] + pub(crate) image_id: Option>, + + #[builder(default, setter(into))] + pub(crate) is_default: Option>, + + #[builder(default, private, setter(name = "_labels"))] + pub(crate) labels: Option, Cow<'a, str>>>, + + #[builder(default, private, setter(name = "_labels_added"))] + pub(crate) labels_added: Option, Cow<'a, str>>>, + + #[builder(default, private, setter(name = "_labels_overridden"))] + pub(crate) labels_overridden: Option, Cow<'a, str>>>, + + #[builder(default, private, setter(name = "_labels_skipped"))] + pub(crate) labels_skipped: Option, Cow<'a, str>>>, + + #[builder(default, setter(into))] + pub(crate) links: Option>>, + + #[builder(default)] + pub(crate) max_node_count: Option, + + #[builder(default, setter(into))] + pub(crate) merge_labels: Option>, + + #[builder(default)] + pub(crate) min_node_count: Option, + + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[builder(default, setter(into))] + pub(crate) node_addresses: Option>>, + + #[builder(default)] + pub(crate) node_count: Option, + + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + #[builder(default, setter(into))] + pub(crate) role: Option>, + + #[builder(default, setter(into))] + pub(crate) stack_id: Option>, + + #[builder(default)] + pub(crate) status: Option, + + #[builder(default, setter(into))] + pub(crate) status_reason: Option>, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(default, setter(into))] + pub(crate) uuid: Option>, + + #[builder(default, setter(into))] + pub(crate) version: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + pub fn labels(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn labels_overridden(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels_overridden + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn labels_added(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels_added + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn labels_skipped(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels_skipped + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "clusters/nodegroups".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.id { + params.push("id", serde_json::to_value(val)?); + } + if let Some(val) = &self.uuid { + params.push("uuid", serde_json::to_value(val)?); + } + if let Some(val) = &self.name { + params.push("name", serde_json::to_value(val)?); + } + if let Some(val) = &self.cluster_id { + params.push("cluster_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.project_id { + params.push("project_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.docker_volume_size { + params.push("docker_volume_size", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels { + params.push("labels", serde_json::to_value(val)?); + } + if let Some(val) = &self.links { + params.push("links", serde_json::to_value(val)?); + } + if let Some(val) = &self.flavor_id { + params.push("flavor_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.image_id { + params.push("image_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.node_addresses { + params.push("node_addresses", serde_json::to_value(val)?); + } + if let Some(val) = &self.node_count { + params.push("node_count", serde_json::to_value(val)?); + } + if let Some(val) = &self.role { + params.push("role", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_node_count { + params.push("min_node_count", serde_json::to_value(val)?); + } + if let Some(val) = &self.max_node_count { + params.push("max_node_count", serde_json::to_value(val)?); + } + if let Some(val) = &self.is_default { + params.push("is_default", serde_json::to_value(val)?); + } + if let Some(val) = &self.stack_id { + params.push("stack_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.status { + params.push("status", serde_json::to_value(val)?); + } + if let Some(val) = &self.status_reason { + params.push("status_reason", serde_json::to_value(val)?); + } + if let Some(val) = &self.version { + params.push("version", serde_json::to_value(val)?); + } + if let Some(val) = &self.merge_labels { + params.push("merge_labels", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels_overridden { + params.push("labels_overridden", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels_added { + params.push("labels_added", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels_skipped { + params.push("labels_skipped", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters/nodegroups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clusters/nodegroups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete.rs new file mode 100644 index 000000000..b948cd981 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete.rs @@ -0,0 +1,177 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete NodeGroup for a given project_id and resource. +//! +//! | param cluster_id: | | | --- | --- | | | cluster id. | | param +//! nodegroup_id: | | | | resource name. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// nodegroup_id parameter for /v1/clusters/nodegroups/{nodegroup_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clusters/nodegroups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/clusters/nodegroups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/clusters/nodegroups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete_all.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete_all.rs new file mode 100644 index 000000000..3f9e70504 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete_all.rs @@ -0,0 +1,169 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete NodeGroup for a given project_id and resource. +//! +//! | param cluster_id: | | | --- | --- | | | cluster id. | | param +//! nodegroup_id: | | | | resource name. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + "clusters/nodegroups".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/clusters/nodegroups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/clusters/nodegroups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/find.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/find.rs new file mode 100644 index 000000000..f2dadd742 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/find.rs @@ -0,0 +1,114 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::find::Findable; +use crate::api::rest_endpoint_prelude::*; +use crate::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::api::container_infrastructure_management::v1::cluster::nodegroup::{ + get as Get, list as List, +}; + +/// Find for cluster/nodegroup by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} + +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> Findable for Request<'a> { + type G = Get::Request<'a>; + type L = List::Request; + fn get_ep(&self) -> Get::Request<'a> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().unwrap() + } + fn list_ep(&self) -> List::Request { + let mut ep = List::Request::builder(); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().unwrap() + } + /// Locate cluster/nodegroup in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // cluster/nodegroup is not supporting name as query parameter to the list. + // Therefore it is necessary to go through complete list of results. + let mut maybe_result: Option = None; + for item in data.iter() { + trace!("Validate item {:?} is what we search for", item); + if let Some(name_as_val) = item.get("name") { + if let Some(name) = name_as_val.as_str() { + if name == self.id { + if maybe_result.is_none() { + maybe_result = Some(item.clone()); + } else { + return Err(ApiError::IdNotUnique); + } + } + } + } + } + maybe_result.ok_or(ApiError::ResourceNotFound) + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/get.rs new file mode 100644 index 000000000..72a80764d --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/get.rs @@ -0,0 +1,177 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Retrieve information for the given nodegroup in a cluster. +//! +//! | | | | --- | --- | | param id: | cluster id. | | param resource: | +//! nodegroup id. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// nodegroup_id parameter for /v1/clusters/nodegroups/{nodegroup_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clusters/nodegroups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/clusters/nodegroups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/clusters/nodegroups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/list.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/list.rs new file mode 100644 index 000000000..3aeb86a98 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/list.rs @@ -0,0 +1,176 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Retrieve a list of nodegroups. +//! +//! | param cluster_id: | | | --- | --- | | | the cluster id or name | | param +//! marker: | pagination marker for large data sets. | | param limit: | maximum +//! number of resources to return in a single result. | | param sort_key: | +//! column to sort results by. Default: id. | | param sort_dir: | direction to +//! sort. "asc" or "desc". Default: asc. | | param role: | list all nodegroups +//! with the specified role. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "clusters/nodegroups".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + Some("nodegroups".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "nodegroups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clusters/nodegroups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "nodegroups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clusters/nodegroups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "nodegroups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/set.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/set.rs new file mode 100644 index 000000000..54529e3a2 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/set.rs @@ -0,0 +1,234 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Update NodeGroup. +//! +//! | param cluster_id: | | | --- | --- | | | cluster id. | +//! +//! System Message: WARNING/2 (, line 4) +//! +//! Field list ends without a blank line; unexpected unindent. +//! +//! :param : resource name. :param values: a json document to update a +//! nodegroup. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Op { + #[serde(rename = "add")] + Add, + #[serde(rename = "remove")] + Remove, + #[serde(rename = "replace")] + Replace, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder()] + pub(crate) op: Op, + + #[builder(setter(into))] + pub(crate) path: Cow<'a, str>, + + #[builder(default, setter(into))] + pub(crate) value: Option>, + + /// nodegroup_id parameter for /v1/clusters/nodegroups/{nodegroup_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clusters/nodegroups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("path", serde_json::to_value(&self.path)?); + params.push("op", serde_json::to_value(&self.op)?); + if let Some(val) = &self.value { + params.push("value", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .path("foo") + .op(Op::Add) + .build() + .unwrap() + .service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .path("foo") + .op(Op::Add) + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/clusters/nodegroups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .path("foo") + .op(Op::Add) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/clusters/nodegroups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .path("foo") + .op(Op::Add) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/set.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/set.rs new file mode 100644 index 000000000..dc643cb75 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/set.rs @@ -0,0 +1,235 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Update information of one cluster attributes using operations including: +//! `add`, `replace` or `remove`. The attributes to `add` and `replace` in the +//! form of `key=value` while `remove` only needs the keys. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Op { + #[serde(rename = "add")] + Add, + #[serde(rename = "remove")] + Remove, + #[serde(rename = "replace")] + Replace, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The operation used to modify resource’s attributes. Supported + /// operations are following: `add`, `replace` and `remove`. In case of + /// `remove`, users only need to provide `path` for deleting attribute. + /// + #[builder()] + pub(crate) op: Op, + + /// Resource attribute’s name. + /// + #[builder(setter(into))] + pub(crate) path: Cow<'a, str>, + + /// Resource attribute’s value. + /// + #[builder(default, setter(into))] + pub(crate) value: Option>, + + /// cluster_id parameter for /v1/clusters/{cluster_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clusters/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("path", serde_json::to_value(&self.path)?); + params.push("op", serde_json::to_value(&self.op)?); + if let Some(val) = &self.value { + params.push("value", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .path("foo") + .op(Op::Add) + .build() + .unwrap() + .service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .path("foo") + .op(Op::Add) + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/clusters/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .path("foo") + .op(Op::Add) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/clusters/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .path("foo") + .op(Op::Add) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate.rs new file mode 100644 index 000000000..5e549f73c --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate.rs @@ -0,0 +1,22 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/clustertemplates/{id}` REST operations of container_infrastructure_management +pub mod create; +pub mod delete; +pub mod get; +pub mod list; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/create.rs new file mode 100644 index 000000000..80635952d --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/create.rs @@ -0,0 +1,578 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create new cluster template. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Coe { + #[serde(rename = "kubernetes")] + Kubernetes, +} + +/// A link representation. +/// +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Links<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) href: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rel: Option>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _type: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum ServerType { + #[serde(rename = "bm")] + Bm, + #[serde(rename = "vm")] + Vm, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default)] + pub(crate) apiserver_port: Option, + + #[builder(default, setter(into))] + pub(crate) cluster_distro: Option>, + + /// Specify the Container Orchestration Engine to use. Supported COEs + /// include `kubernetes`. If your environment has additional cluster + /// drivers installed, refer to the cluster driver documentation for the + /// new COE names. + /// + #[builder(default)] + pub(crate) coe: Option, + + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + /// The DNS nameserver for the servers and containers in the cluster to + /// use. This is configured in the private Neutron network for the cluster. + /// The default is `8.8.8.8`. + /// + #[builder(default, setter(into))] + pub(crate) dns_nameserver: Option>, + + /// The name of a driver to manage the storage for the images and the + /// container’s writable layer. The default is `devicemapper`. + /// + #[builder(default, setter(into))] + pub(crate) docker_storage_driver: Option>, + + /// The size in GB for the local storage on each server for the Docker + /// daemon to cache the images and host the containers. Cinder volumes + /// provide the storage. The default is 25 GB. For the `devicemapper` + /// storage driver, the minimum value is 3GB. For the `overlay` storage + /// driver, the minimum value is 1GB. + /// + #[builder(default)] + pub(crate) docker_volume_size: Option, + + #[builder(default, setter(into))] + pub(crate) driver: Option>, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the external internet for the cluster. This network must be an external + /// network, i.e. its attribute `router:external` must be `True`. The + /// servers in the cluster will be connected to a private network and + /// Magnum will create a router between this private network and the + /// external network. This will allow the servers to download images, + /// access discovery service, etc, and the containers to install packages, + /// etc. In the opposite direction, floating IPs will be allocated from the + /// external network to provide access from the external internet to + /// servers and the container services hosted in the cluster. + /// + #[builder(default, setter(into))] + pub(crate) external_network_id: Option>, + + /// The name or network ID of a Neutron network to provide connectivity to + /// the internal network for the cluster. + /// + #[builder(default, setter(into))] + pub(crate) fixed_network: Option>, + + /// Fixed subnet that are using to allocate network address for nodes in + /// cluster. + /// + #[builder(default, setter(into))] + pub(crate) fixed_subnet: Option>, + + /// The nova flavor ID or name for booting the node servers. The default is + /// `m1.small`. + /// + #[builder(default, setter(into))] + pub(crate) flavor_id: Option>, + + /// Whether enable or not using the floating IP of cloud provider. Some + /// cloud providers used floating IP, some used public IP, thus Magnum + /// provide this option for specifying the choice of using floating IP. + /// + #[builder(default, setter(into))] + pub(crate) floating_ip_enabled: Option>, + + /// Indicates whether the ClusterTemplate is hidden or not, the default + /// value is false. + /// + #[builder(default, setter(into))] + pub(crate) hidden: Option>, + + /// The IP address for a proxy to use when direct http access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[builder(default, setter(into))] + pub(crate) http_proxy: Option>, + + /// The IP address for a proxy to use when direct https access from the + /// servers to sites on the external internet is blocked. This may happen + /// in certain countries or enterprises, and the proxy allows the servers + /// and containers to access these sites. The format is a URL including a + /// port number. The default is `None`. + /// + #[builder(default, setter(into))] + pub(crate) https_proxy: Option>, + + /// The name or UUID of the base image in Glance to boot the servers for + /// the cluster. The image must have the attribute `os_distro` defined as + /// appropriate for the cluster driver. + /// + #[builder(setter(into))] + pub(crate) image_id: Cow<'a, str>, + + #[builder(default, setter(into))] + pub(crate) insecure_registry: Option>, + + /// The name of the SSH keypair to configure in the cluster servers for ssh + /// access. Users will need the key to be able to ssh to the servers in the + /// cluster. The login name is specific to the cluster driver, for example + /// with fedora-atomic image, default login name is `fedora`. + /// + #[builder(default, setter(into))] + pub(crate) keypair_id: Option>, + + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + #[builder(default, private, setter(name = "_labels"))] + pub(crate) labels: Option, Cow<'a, str>>>, + + #[builder(default, setter(into))] + pub(crate) links: Option>>, + + /// The flavor of the master node for this cluster template. + /// + #[builder(default, setter(into))] + pub(crate) master_flavor_id: Option>, + + /// Since multiple masters may exist in a cluster, a Neutron load balancer + /// is created to provide the API endpoint for the cluster and to direct + /// requests to the masters. In some cases, such as when the LBaaS service + /// is not available, this option can be set to `false` to create a cluster + /// without the load balancer. In this case, one of the masters will serve + /// as the API endpoint. The default is `true`, i.e. to create the load + /// balancer for the cluster. + /// + #[builder(default, setter(into))] + pub(crate) master_lb_enabled: Option>, + + /// Name of the resource. + /// + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The name of a network driver for providing the networks for the + /// containers. Note that this is different and separate from the Neutron + /// network for the cluster. The operation and networking model are + /// specific to the particular driver. + /// + #[builder(default, setter(into))] + pub(crate) network_driver: Option>, + + /// When a proxy server is used, some sites should not go through the proxy + /// and should be accessed normally. In this case, users can specify these + /// sites as a comma separated list of IPs. The default is `None`. + /// + #[builder(default, setter(into))] + pub(crate) no_proxy: Option>, + + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// Access to a cluster template is normally limited to the admin, owner or + /// users within the same tenant as the owners. Setting this flag makes the + /// cluster template public and accessible by other users. The default is + /// not public. + /// + #[builder(default, setter(into))] + pub(crate) public: Option>, + + /// Docker images by default are pulled from the public Docker registry, + /// but in some cases, users may want to use a private registry. This + /// option provides an alternative registry based on the Registry V2: + /// Magnum will create a local registry in the cluster backed by swift to + /// host the images. The default is to use the public registry. + /// + #[builder(default, setter(into))] + pub(crate) registry_enabled: Option>, + + /// The servers in the cluster can be `vm` or `baremetal`. This parameter + /// selects the type of server to create for the cluster. The default is + /// `vm`. + /// + #[builder(default)] + pub(crate) server_type: Option, + + /// Administrator tags for the cluster template. + /// + #[builder(default, setter(into))] + pub(crate) tags: Option>, + + /// Transport Layer Security (TLS) is normally enabled to secure the + /// cluster. In some cases, users may want to disable TLS in the cluster, + /// for instance during development or to troubleshoot certain problems. + /// Specifying this parameter will disable TLS so that users can access the + /// COE endpoints without a certificate. The default is TLS enabled. + /// + #[builder(default, setter(into))] + pub(crate) tls_disabled: Option>, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(default, setter(into))] + pub(crate) user_id: Option>, + + #[builder(default, setter(into))] + pub(crate) uuid: Option>, + + /// The name of a volume driver for managing the persistent storage for the + /// containers. The functionality supported are specific to the driver. + /// + #[builder(default, setter(into))] + pub(crate) volume_driver: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Arbitrary labels in the form of `key=value` pairs. The accepted keys + /// and valid values are defined in the cluster drivers. They are used as a + /// way to pass additional parameters that are specific to a cluster + /// driver. + /// + pub fn labels(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.labels + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Clustertemplate. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "clustertemplates".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.uuid { + params.push("uuid", serde_json::to_value(val)?); + } + if let Some(val) = &self.name { + params.push("name", serde_json::to_value(val)?); + } + if let Some(val) = &self.coe { + params.push("coe", serde_json::to_value(val)?); + } + params.push("image_id", serde_json::to_value(&self.image_id)?); + if let Some(val) = &self.flavor_id { + params.push("flavor_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.master_flavor_id { + params.push("master_flavor_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.dns_nameserver { + params.push("dns_nameserver", serde_json::to_value(val)?); + } + if let Some(val) = &self.keypair_id { + params.push("keypair_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.external_network_id { + params.push("external_network_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.fixed_network { + params.push("fixed_network", serde_json::to_value(val)?); + } + if let Some(val) = &self.fixed_subnet { + params.push("fixed_subnet", serde_json::to_value(val)?); + } + if let Some(val) = &self.network_driver { + params.push("network_driver", serde_json::to_value(val)?); + } + if let Some(val) = &self.apiserver_port { + params.push("apiserver_port", serde_json::to_value(val)?); + } + if let Some(val) = &self.docker_volume_size { + params.push("docker_volume_size", serde_json::to_value(val)?); + } + if let Some(val) = &self.cluster_distro { + params.push("cluster_distro", serde_json::to_value(val)?); + } + if let Some(val) = &self.links { + params.push("links", serde_json::to_value(val)?); + } + if let Some(val) = &self.http_proxy { + params.push("http_proxy", serde_json::to_value(val)?); + } + if let Some(val) = &self.https_proxy { + params.push("https_proxy", serde_json::to_value(val)?); + } + if let Some(val) = &self.no_proxy { + params.push("no_proxy", serde_json::to_value(val)?); + } + if let Some(val) = &self.volume_driver { + params.push("volume_driver", serde_json::to_value(val)?); + } + if let Some(val) = &self.registry_enabled { + params.push("registry_enabled", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels { + params.push("labels", serde_json::to_value(val)?); + } + if let Some(val) = &self.tls_disabled { + params.push("tls_disabled", serde_json::to_value(val)?); + } + if let Some(val) = &self.public { + params.push("public", serde_json::to_value(val)?); + } + if let Some(val) = &self.server_type { + params.push("server_type", serde_json::to_value(val)?); + } + if let Some(val) = &self.insecure_registry { + params.push("insecure_registry", serde_json::to_value(val)?); + } + if let Some(val) = &self.docker_storage_driver { + params.push("docker_storage_driver", serde_json::to_value(val)?); + } + if let Some(val) = &self.master_lb_enabled { + params.push("master_lb_enabled", serde_json::to_value(val)?); + } + if let Some(val) = &self.floating_ip_enabled { + params.push("floating_ip_enabled", serde_json::to_value(val)?); + } + if let Some(val) = &self.project_id { + params.push("project_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.user_id { + params.push("user_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.hidden { + params.push("hidden", serde_json::to_value(val)?); + } + if let Some(val) = &self.tags { + params.push("tags", serde_json::to_value(val)?); + } + if let Some(val) = &self.driver { + params.push("driver", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .image_id("foo") + .build() + .unwrap() + .service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .image_id("foo") + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clustertemplates".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().image_id("foo").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/clustertemplates".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/delete.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/delete.rs new file mode 100644 index 000000000..ec8ed8096 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/delete.rs @@ -0,0 +1,175 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete a cluster template. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// clustertemplate_id parameter for + /// /v1/clustertemplates/{clustertemplate_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Clustertemplate. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clustertemplates/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/clustertemplates/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/clustertemplates/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/get.rs new file mode 100644 index 000000000..88a22939a --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/get.rs @@ -0,0 +1,175 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Get all information of a cluster template in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// clustertemplate_id parameter for + /// /v1/clustertemplates/{clustertemplate_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Clustertemplate. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("clustertemplates/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/clustertemplates/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/clustertemplates/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/list.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/list.rs new file mode 100644 index 000000000..5772de1e1 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/list.rs @@ -0,0 +1,169 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List all available cluster templates in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Clustertemplate. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "clustertemplates".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + Some("clustertemplates".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "clustertemplates" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clustertemplates".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "clustertemplates": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clustertemplates".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "clustertemplates": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/federation.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/federation.rs new file mode 100644 index 000000000..b6d96046c --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/federation.rs @@ -0,0 +1,22 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/federations/{id}` REST operations of container_infrastructure_management +pub mod create; +pub mod delete; +pub mod get; +pub mod list; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/create.rs new file mode 100644 index 000000000..621906912 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/create.rs @@ -0,0 +1,302 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create a new federation. +//! +//! | param federation: | | | --- | --- | | | a federation within the request +//! body. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Status { + #[serde(rename = "CREATE_COMPLETE")] + CreateComplete, + #[serde(rename = "CREATE_FAILED")] + CreateFailed, + #[serde(rename = "CREATE_IN_PROGRESS")] + CreateInProgress, + #[serde(rename = "DELETE_COMPLETE")] + DeleteComplete, + #[serde(rename = "DELETE_FAILED")] + DeleteFailed, + #[serde(rename = "DELETE_IN_PROGRESS")] + DeleteInProgress, + #[serde(rename = "UPDATE_COMPLETE")] + UpdateComplete, + #[serde(rename = "UPDATE_FAILED")] + UpdateFailed, + #[serde(rename = "UPDATE_IN_PROGRESS")] + UpdateInProgress, +} + +/// A link representation. +/// +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Links<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) href: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rel: Option>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _type: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[builder(default, setter(into))] + pub(crate) hostcluster_id: Option>, + + #[builder(default, setter(into))] + pub(crate) links: Option>>, + + #[builder(default, setter(into))] + pub(crate) member_ids: Option>>, + + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[builder(default, private, setter(name = "_properties"))] + pub(crate) properties: Option, Cow<'a, str>>>, + + #[builder(default)] + pub(crate) status: Option, + + #[builder(default, setter(into))] + pub(crate) status_reason: Option>, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(default, setter(into))] + pub(crate) uuid: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.properties + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Federation. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "federations".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.uuid { + params.push("uuid", serde_json::to_value(val)?); + } + if let Some(val) = &self.name { + params.push("name", serde_json::to_value(val)?); + } + if let Some(val) = &self.hostcluster_id { + params.push("hostcluster_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.member_ids { + params.push("member_ids", serde_json::to_value(val)?); + } + if let Some(val) = &self.status { + params.push("status", serde_json::to_value(val)?); + } + if let Some(val) = &self.status_reason { + params.push("status_reason", serde_json::to_value(val)?); + } + if let Some(val) = &self.properties { + params.push("properties", serde_json::to_value(val)?); + } + if let Some(val) = &self.links { + params.push("links", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/federations".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/federations".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/delete.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/delete.rs new file mode 100644 index 000000000..88fbba8b1 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/delete.rs @@ -0,0 +1,177 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete a federation. +//! +//! | param federation_ident: | | | --- | --- | | | UUID of federation or +//! logical name of the federation. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// federation_id parameter for /v1/federations/{federation_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Federation. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("federations/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/federations/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/federations/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/get.rs new file mode 100644 index 000000000..f8a784d8c --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/get.rs @@ -0,0 +1,177 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Retrieve information about a given Federation. +//! +//! | param federation_ident: | | | --- | --- | | | UUID or logical name of the +//! Federation. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// federation_id parameter for /v1/federations/{federation_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Federation. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("federations/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/federations/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/federations/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/list.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/list.rs new file mode 100644 index 000000000..9bea1af46 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/list.rs @@ -0,0 +1,174 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Retrieve a list of federations. +//! +//! | | | | --- | --- | | param marker: | pagination marker for large data +//! sets. | | param limit: | maximum number of resources to return in a single +//! result. | | param sort_key: | column to sort results by. Default: id. | | +//! param sort_dir: | direction to sort. "asc" or "desc". Default: asc. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Federation. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "federations".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + Some("federations".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "federations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/federations".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "federations": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/federations".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "federations": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/mservice.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/mservice.rs new file mode 100644 index 000000000..7ccecf489 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/mservice.rs @@ -0,0 +1,19 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/mservices` REST operations of container_infrastructure_management +pub mod list; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/mservice/list.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/mservice/list.rs new file mode 100644 index 000000000..b2b09b4fb --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/mservice/list.rs @@ -0,0 +1,173 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Enables administrative users to list all Magnum services. +//! +//! Container infrastructure service information include service id, binary, +//! host, report count, creation time, last updated time, health status, and +//! the reason for disabling service. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Mservice. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "mservices".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + Some("mservices".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "mservices" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/mservices".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mservices": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/mservices".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mservices": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/quota.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/quota.rs new file mode 100644 index 000000000..42b87671c --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/quota.rs @@ -0,0 +1,22 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/quotas/{id}` REST operations of container_infrastructure_management +pub mod create; +pub mod delete; +pub mod get; +pub mod list; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/create.rs new file mode 100644 index 000000000..8d9ba88d2 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/create.rs @@ -0,0 +1,219 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Create new quota for a project. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Resource { + #[serde(rename = "Cluster")] + Cluster, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + #[builder(default)] + pub(crate) hard_limit: Option, + + #[builder(default)] + pub(crate) id: Option, + + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + #[builder(default)] + pub(crate) resource: Option, + + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "quotas".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.id { + params.push("id", serde_json::to_value(val)?); + } + if let Some(val) = &self.hard_limit { + params.push("hard_limit", serde_json::to_value(val)?); + } + if let Some(val) = &self.project_id { + params.push("project_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.resource { + params.push("resource", serde_json::to_value(val)?); + } + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/quotas".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/quotas".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/delete.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/delete.rs new file mode 100644 index 000000000..1647f0e62 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/delete.rs @@ -0,0 +1,177 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Delete Quota for a given project_id and resource. +//! +//! | param project_id: | | | --- | --- | | | project id. | | param resource: | +//! resource name. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// quota_id parameter for /v1/quotas/{quota_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("quotas/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/quotas/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/quotas/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/get.rs new file mode 100644 index 000000000..796449f5d --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/get.rs @@ -0,0 +1,177 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Retrieve Quota information for the given project_id. +//! +//! | | | | --- | --- | | param id: | project id. | | param resource: | +//! resource name. | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// quota_id parameter for /v1/quotas/{quota_id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl RequestBuilder<'_> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("quotas/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/list.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/list.rs new file mode 100644 index 000000000..ec6c31872 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/list.rs @@ -0,0 +1,169 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! List all quotas in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "quotas".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + Some("quotas".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quotas" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/quotas".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quotas": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/quotas".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quotas": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/stat.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/stat.rs new file mode 100644 index 000000000..8efa11928 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/stat.rs @@ -0,0 +1,19 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1/stats` REST operations of container_infrastructure_management +pub mod get; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/stat/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/stat/get.rs new file mode 100644 index 000000000..638eda0aa --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/stat/get.rs @@ -0,0 +1,167 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! Show overall Magnum system stats. If the requester is non-admin user show +//! self stats. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Stat. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "stats".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/stats".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/stats".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/version.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/version.rs new file mode 100644 index 000000000..447e56909 --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/version.rs @@ -0,0 +1,19 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +//! `/v1` REST operations of container_infrastructure_management +pub mod get; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/version/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/version/get.rs new file mode 100644 index 000000000..f712b1c9b --- /dev/null +++ b/openstack_sdk/src/api/container_infrastructure_management/v1/version/get.rs @@ -0,0 +1,163 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Version. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ContainerInfrastructureManagement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(1, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET).path("/".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +}