Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<String>,

#[arg(help_heading = "Body parameters", long)]
cluster_uuid: Option<String>,

#[arg(help_heading = "Body parameters", long)]
created_at: Option<String>,

#[arg(help_heading = "Body parameters", long)]
csr: Option<String>,

#[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)]
links: Option<Vec<Value>>,

#[arg(help_heading = "Body parameters", long)]
pem: Option<String>,

#[arg(help_heading = "Body parameters", long)]
updated_at: Option<String>,
}

/// 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<String>,

#[serde()]
#[structable(optional)]
cluster_uuid: Option<String>,

#[serde()]
#[structable(optional)]
created_at: Option<String>,

#[serde()]
#[structable(optional)]
csr: Option<String>,

#[serde()]
#[structable(optional, pretty)]
links: Option<Value>,

#[serde()]
#[structable(optional)]
pem: Option<String>,

#[serde()]
#[structable(optional)]
updated_at: Option<String>,
}

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<create::Links> = arg
.iter()
.flat_map(|v| serde_json::from_value::<create::Links>(v.to_owned()))
.collect::<Vec<create::Links>>();
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::<ResponseData>(data)?;
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -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<String>,

/// The UUID of the cluster.
///
#[serde()]
#[structable(optional)]
cluster_uuid: Option<String>,

#[serde()]
#[structable(optional)]
created_at: Option<String>,

#[serde()]
#[structable(optional)]
csr: Option<String>,

/// Links to the resources in question.
///
#[serde()]
#[structable(optional, pretty)]
links: Option<Value>,

/// CA certificate for the cluster.
///
#[serde()]
#[structable(optional)]
pem: Option<String>,

#[serde()]
#[structable(optional)]
updated_at: Option<String>,
}

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::<ResponseData>(data)?;
Ok(())
}
}
Loading