diff --git a/openstack_cli/src/cli.rs b/openstack_cli/src/cli.rs index 411357273..efe42d6f1 100644 --- a/openstack_cli/src/cli.rs +++ b/openstack_cli/src/cli.rs @@ -29,6 +29,7 @@ use crate::auth; use crate::block_storage::v3 as block_storage; use crate::catalog; use crate::compute::v2 as compute; +use crate::dns::v2 as dns; use crate::identity::v3 as identity; use crate::image::v2 as image; use crate::load_balancer::v2 as load_balancer; @@ -168,6 +169,7 @@ pub enum TopLevelCommands { BlockStorage(block_storage::BlockStorageCommand), Catalog(catalog::CatalogCommand), Compute(compute::ComputeCommand), + Dns(dns::DnsCommand), Identity(identity::IdentityCommand), Image(image::ImageCommand), LoadBalancer(load_balancer::LoadBalancerCommand), @@ -202,6 +204,7 @@ impl Cli { TopLevelCommands::BlockStorage(args) => args.take_action(self, client).await, TopLevelCommands::Catalog(args) => args.take_action(self, client).await, TopLevelCommands::Compute(args) => args.take_action(self, client).await, + TopLevelCommands::Dns(args) => args.take_action(self, client).await, TopLevelCommands::Identity(args) => args.take_action(self, client).await, TopLevelCommands::Image(args) => args.take_action(self, client).await, TopLevelCommands::LoadBalancer(args) => args.take_action(self, client).await, diff --git a/openstack_cli/src/dns/mod.rs b/openstack_cli/src/dns/mod.rs index a2b8d3f07..9bc2bc79e 100644 --- a/openstack_cli/src/dns/mod.rs +++ b/openstack_cli/src/dns/mod.rs @@ -13,3 +13,4 @@ // SPDX-License-Identifier: Apache-2.0 //! DNS (Designate) API bindings +pub(super) mod v2; diff --git a/openstack_cli/src/dns/v2.rs b/openstack_cli/src/dns/v2.rs new file mode 100644 index 000000000..3fd90c912 --- /dev/null +++ b/openstack_cli/src/dns/v2.rs @@ -0,0 +1,56 @@ +// 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 + +//! DNS API v2 command + +use clap::{Parser, Subcommand}; + +use openstack_sdk::{types::ServiceType, AsyncOpenStack}; + +use crate::{Cli, OpenStackCliError}; + +mod recordset; +mod zone; + +/// DNS service (Designate) operations +#[derive(Parser)] +pub struct DnsCommand { + /// Dns service resource + #[command(subcommand)] + command: DnsCommands, +} + +/// Dns resources commands +#[allow(missing_docs)] +#[derive(Subcommand)] +pub enum DnsCommands { + Recordset(Box), + Zone(Box), +} + +impl DnsCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + session: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + session.discover_service_endpoint(&ServiceType::Dns).await?; + + match &self.command { + DnsCommands::Recordset(cmd) => cmd.take_action(parsed_args, session).await, + DnsCommands::Zone(cmd) => cmd.take_action(parsed_args, session).await, + } + } +} diff --git a/openstack_cli/src/dns/v2/recordset.rs b/openstack_cli/src/dns/v2/recordset.rs new file mode 100644 index 000000000..1820dcce4 --- /dev/null +++ b/openstack_cli/src/dns/v2/recordset.rs @@ -0,0 +1,52 @@ +// 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 + +//! DNS project Recordsets management +use clap::{Parser, Subcommand}; + +use openstack_sdk::AsyncOpenStack; + +use crate::{Cli, OpenStackCliError}; + +mod list; + +/// DNS Project recordsets operations +/// +/// This command manages all Recordsets owned by a project. +#[derive(Parser)] +pub struct RecordsetCommand { + /// subcommand + #[command(subcommand)] + command: RecordsetCommands, +} + +/// Supported subcommands +#[allow(missing_docs)] +#[derive(Subcommand)] +pub enum RecordsetCommands { + List(list::RecordsetsCommand), +} + +impl RecordsetCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + session: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + match &self.command { + RecordsetCommands::List(cmd) => cmd.take_action(parsed_args, session).await, + } + } +} diff --git a/openstack_cli/src/dns/v2/zone.rs b/openstack_cli/src/dns/v2/zone.rs new file mode 100644 index 000000000..ee50a980f --- /dev/null +++ b/openstack_cli/src/dns/v2/zone.rs @@ -0,0 +1,68 @@ +// 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 + +//! DNS Zone management +use clap::{Parser, Subcommand}; + +use openstack_sdk::AsyncOpenStack; + +use crate::{Cli, OpenStackCliError}; + +mod create; +mod delete; +mod list; +mod nameserver; +mod recordset; +mod set; +mod show; + +/// DNS Zone operations +#[derive(Parser)] +pub struct ZoneCommand { + /// subcommand + #[command(subcommand)] + command: ZoneCommands, +} + +/// Supported subcommands +#[allow(missing_docs)] +#[derive(Subcommand)] +pub enum ZoneCommands { + Create(create::ZoneCommand), + Delete(delete::ZoneCommand), + List(list::ZonesCommand), + Nameserver(nameserver::NameserverCommand), + Recordset(recordset::RecordsetCommand), + Show(show::ZoneCommand), + Set(set::ZoneCommand), +} + +impl ZoneCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + session: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + match &self.command { + ZoneCommands::Create(cmd) => cmd.take_action(parsed_args, session).await, + ZoneCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await, + ZoneCommands::List(cmd) => cmd.take_action(parsed_args, session).await, + ZoneCommands::Nameserver(cmd) => cmd.take_action(parsed_args, session).await, + ZoneCommands::Recordset(cmd) => cmd.take_action(parsed_args, session).await, + ZoneCommands::Show(cmd) => cmd.take_action(parsed_args, session).await, + ZoneCommands::Set(cmd) => cmd.take_action(parsed_args, session).await, + } + } +} diff --git a/openstack_cli/src/dns/v2/zone/nameserver.rs b/openstack_cli/src/dns/v2/zone/nameserver.rs new file mode 100644 index 000000000..fe5bd7250 --- /dev/null +++ b/openstack_cli/src/dns/v2/zone/nameserver.rs @@ -0,0 +1,50 @@ +// 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 + +//! DNS Zone Nameserver management +use clap::{Parser, Subcommand}; + +use openstack_sdk::AsyncOpenStack; + +use crate::{Cli, OpenStackCliError}; + +mod list; + +/// DNS recordsets operations +#[derive(Parser)] +pub struct NameserverCommand { + /// subcommand + #[command(subcommand)] + command: NameserverCommands, +} + +/// Supported subcommands +#[allow(missing_docs)] +#[derive(Subcommand)] +pub enum NameserverCommands { + List(list::NameserversCommand), +} + +impl NameserverCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + session: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + match &self.command { + NameserverCommands::List(cmd) => cmd.take_action(parsed_args, session).await, + } + } +} diff --git a/openstack_cli/src/dns/v2/zone/nameserver/get.rs b/openstack_cli/src/dns/v2/zone/nameserver/get.rs deleted file mode 100644 index c3cf75beb..000000000 --- a/openstack_cli/src/dns/v2/zone/nameserver/get.rs +++ /dev/null @@ -1,114 +0,0 @@ -// 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 Nameserver command -//! -//! Wraps invoking of the `v2/zones/{zone_id}/nameservers` 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::dns::v2::zone::nameserver::get; -use openstack_sdk::api::QueryAsync; -use serde_json::Value; -use std::collections::HashMap; - -/// Show the nameservers for a zone -/// -#[derive(Args)] -#[command(about = "Get the Name Servers for a Zone")] -pub struct NameserverCommand { - /// 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 { - /// zone_id parameter for /v2/zones/{zone_id}/nameservers API - /// - #[arg( - help_heading = "Path parameters", - id = "path_param_zone_id", - value_name = "ZONE_ID" - )] - zone_id: String, -} -/// Response data as HashMap type -#[derive(Deserialize, Serialize)] -struct ResponseData(HashMap); - -impl StructTable for ResponseData { - fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { - let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); - let mut rows: Vec> = Vec::new(); - rows.extend(self.0.iter().map(|(k, v)| { - Vec::from([ - k.clone(), - serde_json::to_string(&v).expect("Is a valid data"), - ]) - })); - (headers, rows) - } -} - -impl NameserverCommand { - /// Perform command action - pub async fn take_action( - &self, - parsed_args: &Cli, - client: &mut AsyncOpenStack, - ) -> Result<(), OpenStackCliError> { - info!("Get Nameserver"); - - let op = OutputProcessor::from_args(parsed_args); - op.validate_args(parsed_args)?; - - let mut ep_builder = get::Request::builder(); - - // Set path parameters - ep_builder.zone_id(&self.path.zone_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/dns/v2/zone/recordset.rs b/openstack_cli/src/dns/v2/zone/recordset.rs new file mode 100644 index 000000000..af6c5bf8f --- /dev/null +++ b/openstack_cli/src/dns/v2/zone/recordset.rs @@ -0,0 +1,62 @@ +// 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 + +//! DNS Zone Recordsets management +use clap::{Parser, Subcommand}; + +use openstack_sdk::AsyncOpenStack; + +use crate::{Cli, OpenStackCliError}; + +mod create; +mod delete; +mod list; +mod set; +mod show; + +/// DNS recordsets operations +#[derive(Parser)] +pub struct RecordsetCommand { + /// subcommand + #[command(subcommand)] + command: RecordsetCommands, +} + +/// Supported subcommands +#[allow(missing_docs)] +#[derive(Subcommand)] +pub enum RecordsetCommands { + Create(create::RecordsetCommand), + Delete(delete::RecordsetCommand), + List(list::RecordsetsCommand), + Show(show::RecordsetCommand), + Set(set::RecordsetCommand), +} + +impl RecordsetCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + session: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + match &self.command { + RecordsetCommands::Create(cmd) => cmd.take_action(parsed_args, session).await, + RecordsetCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await, + RecordsetCommands::List(cmd) => cmd.take_action(parsed_args, session).await, + RecordsetCommands::Show(cmd) => cmd.take_action(parsed_args, session).await, + RecordsetCommands::Set(cmd) => cmd.take_action(parsed_args, session).await, + } + } +} diff --git a/openstack_cli/src/dns/v2/zone/recordset/list.rs b/openstack_cli/src/dns/v2/zone/recordset/list.rs index a8090df34..d4fff4355 100644 --- a/openstack_cli/src/dns/v2/zone/recordset/list.rs +++ b/openstack_cli/src/dns/v2/zone/recordset/list.rs @@ -122,16 +122,20 @@ struct QueryParameters { /// #[arg(help_heading = "Query parameters", long)] ttl: Option, - - /// ID of the zone - /// - #[arg(help_heading = "Query parameters", long)] - zone_id: Option, } /// Path parameters #[derive(Args)] -struct PathParameters {} +struct PathParameters { + /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_zone_id", + value_name = "ZONE_ID" + )] + zone_id: String, +} /// Recordsets response representation #[derive(Deserialize, Serialize, Clone, StructTable)] struct ResponseData { @@ -229,10 +233,8 @@ impl RecordsetsCommand { let mut ep_builder = list::Request::builder(); // Set path parameters + ep_builder.zone_id(&self.path.zone_id); // Set query parameters - if let Some(val) = &self.query.zone_id { - ep_builder.zone_id(val); - } if let Some(val) = &self.query.limit { ep_builder.limit(*val); } diff --git a/openstack_cli/src/dns/v2/zone/recordset/set.rs b/openstack_cli/src/dns/v2/zone/recordset/set.rs index b3977c48b..622483259 100644 --- a/openstack_cli/src/dns/v2/zone/recordset/set.rs +++ b/openstack_cli/src/dns/v2/zone/recordset/set.rs @@ -31,7 +31,6 @@ use crate::OpenStackCliError; use crate::OutputConfig; use crate::StructTable; -use crate::common::parse_json; use crate::common::parse_key_val; use openstack_sdk::api::dns::v2::zone::recordset::find; use openstack_sdk::api::dns::v2::zone::recordset::set; diff --git a/openstack_cli/src/dns/v2/zone/set.rs b/openstack_cli/src/dns/v2/zone/set.rs index 2a70815a7..d6fa9392a 100644 --- a/openstack_cli/src/dns/v2/zone/set.rs +++ b/openstack_cli/src/dns/v2/zone/set.rs @@ -31,7 +31,6 @@ use crate::OpenStackCliError; use crate::OutputConfig; use crate::StructTable; -use crate::common::parse_json; use crate::common::parse_key_val; use openstack_sdk::api::dns::v2::zone::find; use openstack_sdk::api::dns::v2::zone::set; diff --git a/openstack_cli/tests/dns/mod.rs b/openstack_cli/tests/dns/mod.rs new file mode 100644 index 000000000..4e5ae44c4 --- /dev/null +++ b/openstack_cli/tests/dns/mod.rs @@ -0,0 +1,15 @@ +// 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 + +mod v2; diff --git a/openstack_cli/tests/dns/v2/zone/nameserver/get_autogen.rs b/openstack_cli/tests/dns/v2/mod.rs similarity index 78% rename from openstack_cli/tests/dns/v2/zone/nameserver/get_autogen.rs rename to openstack_cli/tests/dns/v2/mod.rs index c6b7aaccb..4f161837d 100644 --- a/openstack_cli/tests/dns/v2/zone/nameserver/get_autogen.rs +++ b/openstack_cli/tests/dns/v2/mod.rs @@ -11,9 +11,9 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -// -// WARNING: This file is automatically generated from OpenAPI schema using -// `openstack-codegenerator`. + +mod recordset; +mod zone; use assert_cmd::prelude::*; use std::process::Command; @@ -22,11 +22,7 @@ use std::process::Command; fn help() -> Result<(), Box> { let mut cmd = Command::cargo_bin("osc")?; - cmd.arg("dns") - .arg("zone") - .arg("nameserver") - .arg("get") - .arg("--help"); + cmd.arg("dns").arg("--help"); cmd.assert().success(); Ok(()) diff --git a/openstack_cli/tests/dns/v2/recordset/mod.rs b/openstack_cli/tests/dns/v2/recordset/mod.rs new file mode 100644 index 000000000..cd3ec145d --- /dev/null +++ b/openstack_cli/tests/dns/v2/recordset/mod.rs @@ -0,0 +1,28 @@ +// 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 + +mod list_autogen; + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("dns").arg("recordset").arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/dns/v2/zone/mod.rs b/openstack_cli/tests/dns/v2/zone/mod.rs new file mode 100644 index 000000000..250244ad2 --- /dev/null +++ b/openstack_cli/tests/dns/v2/zone/mod.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 + +mod create_autogen; +mod delete_autogen; +mod list_autogen; +mod set_autogen; +mod show_autogen; + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("dns").arg("zone").arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/dns/v2/zone/nameserver/mod.rs b/openstack_cli/tests/dns/v2/zone/nameserver/mod.rs new file mode 100644 index 000000000..693092cf9 --- /dev/null +++ b/openstack_cli/tests/dns/v2/zone/nameserver/mod.rs @@ -0,0 +1,28 @@ +// 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 + +mod get_autogen; + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("dns").arg("zone").arg("nameserver").arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/dns/v2/zone/recordset/mod.rs b/openstack_cli/tests/dns/v2/zone/recordset/mod.rs new file mode 100644 index 000000000..25dbcdf34 --- /dev/null +++ b/openstack_cli/tests/dns/v2/zone/recordset/mod.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 + +mod create_autogen; +mod delete_autogen; +mod list_autogen; +mod set_autogen; +mod show_autogen; + +use assert_cmd::prelude::*; +use std::process::Command; + +#[test] +fn help() -> Result<(), Box> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("dns").arg("zone").arg("recordset").arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/main.rs b/openstack_cli/tests/main.rs index cd67a1998..31f3e4041 100644 --- a/openstack_cli/tests/main.rs +++ b/openstack_cli/tests/main.rs @@ -20,6 +20,8 @@ mod block_storage; mod catalog; #[cfg(feature = "compute")] mod compute; +#[cfg(feature = "dns")] +mod dns; #[cfg(feature = "identity")] mod identity; #[cfg(feature = "image")] diff --git a/openstack_sdk/src/api/dns.rs b/openstack_sdk/src/api/dns.rs index a9e79137b..7b3b53f77 100644 --- a/openstack_sdk/src/api/dns.rs +++ b/openstack_sdk/src/api/dns.rs @@ -13,3 +13,4 @@ // SPDX-License-Identifier: Apache-2.0 //! DNS service (Designate) bindings +pub mod v2; diff --git a/openstack_sdk/src/api/dns/v2/blacklist/create.rs b/openstack_sdk/src/api/dns/v2/blacklist/create.rs index fb035ec16..3cdf91a88 100644 --- a/openstack_sdk/src/api/dns/v2/blacklist/create.rs +++ b/openstack_sdk/src/api/dns/v2/blacklist/create.rs @@ -95,7 +95,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/blacklist/set.rs b/openstack_sdk/src/api/dns/v2/blacklist/set.rs index df842daf3..cc7eb9d0e 100644 --- a/openstack_sdk/src/api/dns/v2/blacklist/set.rs +++ b/openstack_sdk/src/api/dns/v2/blacklist/set.rs @@ -105,7 +105,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/pool/create.rs b/openstack_sdk/src/api/dns/v2/pool/create.rs index 654c9722f..ef325238b 100644 --- a/openstack_sdk/src/api/dns/v2/pool/create.rs +++ b/openstack_sdk/src/api/dns/v2/pool/create.rs @@ -95,7 +95,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/pool/set.rs b/openstack_sdk/src/api/dns/v2/pool/set.rs index 8727f8f3b..5818baa2c 100644 --- a/openstack_sdk/src/api/dns/v2/pool/set.rs +++ b/openstack_sdk/src/api/dns/v2/pool/set.rs @@ -101,7 +101,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/quota/set.rs b/openstack_sdk/src/api/dns/v2/quota/set.rs index f86906bb4..d4196246d 100644 --- a/openstack_sdk/src/api/dns/v2/quota/set.rs +++ b/openstack_sdk/src/api/dns/v2/quota/set.rs @@ -105,7 +105,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/reverse/floatingip/set.rs b/openstack_sdk/src/api/dns/v2/reverse/floatingip/set.rs index 4ecb94b43..0e8fa9af3 100644 --- a/openstack_sdk/src/api/dns/v2/reverse/floatingip/set.rs +++ b/openstack_sdk/src/api/dns/v2/reverse/floatingip/set.rs @@ -106,7 +106,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/tld/create.rs b/openstack_sdk/src/api/dns/v2/tld/create.rs index d40853f21..82583be8c 100644 --- a/openstack_sdk/src/api/dns/v2/tld/create.rs +++ b/openstack_sdk/src/api/dns/v2/tld/create.rs @@ -95,7 +95,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/tld/set.rs b/openstack_sdk/src/api/dns/v2/tld/set.rs index 2fcb54c54..0653933c9 100644 --- a/openstack_sdk/src/api/dns/v2/tld/set.rs +++ b/openstack_sdk/src/api/dns/v2/tld/set.rs @@ -101,7 +101,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/tsigkey/create.rs b/openstack_sdk/src/api/dns/v2/tsigkey/create.rs index b3040c824..7948868d9 100644 --- a/openstack_sdk/src/api/dns/v2/tsigkey/create.rs +++ b/openstack_sdk/src/api/dns/v2/tsigkey/create.rs @@ -95,7 +95,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/tsigkey/set.rs b/openstack_sdk/src/api/dns/v2/tsigkey/set.rs index ee7583845..9abc80b4f 100644 --- a/openstack_sdk/src/api/dns/v2/tsigkey/set.rs +++ b/openstack_sdk/src/api/dns/v2/tsigkey/set.rs @@ -101,7 +101,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/nameserver/get.rs b/openstack_sdk/src/api/dns/v2/zone/nameserver/get.rs deleted file mode 100644 index 780de26a2..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/nameserver/get.rs +++ /dev/null @@ -1,178 +0,0 @@ -// 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 the nameservers for a zone -//! -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> { - /// zone_id parameter for /v2/zones/{zone_id}/nameservers API - /// - #[builder(default, setter(into))] - zone_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<'a> RequestBuilder<'a> { - /// Add a single header to the Nameserver. - 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> RestEndpoint for Request<'a> { - fn method(&self) -> http::Method { - http::Method::GET - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "zones/{zone_id}/nameservers", - zone_id = self.zone_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Dns - } - - 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(2, 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::Dns - ); - } - - #[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!("/zones/{zone_id}/nameservers", zone_id = "zone_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().zone_id("zone_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!("/zones/{zone_id}/nameservers", zone_id = "zone_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() - .zone_id("zone_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/dns/v2/zone/recordset/list.rs b/openstack_sdk/src/api/dns/v2/zone/recordset/list.rs index eec81255d..5ecc4374c 100644 --- a/openstack_sdk/src/api/dns/v2/zone/recordset/list.rs +++ b/openstack_sdk/src/api/dns/v2/zone/recordset/list.rs @@ -94,10 +94,10 @@ pub struct Request<'a> { #[builder(default)] ttl: Option, - /// ID of the zone + /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} API /// #[builder(default, setter(into))] - zone_id: Option>, + zone_id: Cow<'a, str>, #[builder(setter(name = "_headers"), default, private)] _headers: Option, @@ -140,12 +140,15 @@ impl<'a> RestEndpoint for Request<'a> { } fn endpoint(&self) -> Cow<'static, str> { - "zones/{zone_id}/recordsets".to_string().into() + format!( + "zones/{zone_id}/recordsets", + zone_id = self.zone_id.as_ref(), + ) + .into() } fn parameters(&self) -> QueryParams { let mut params = QueryParams::default(); - params.push_opt("zone_id", self.zone_id.as_ref()); params.push_opt("limit", self.limit); params.push_opt("market", self.market.as_ref()); params.push_opt("sort_dir", self.sort_dir.as_ref()); @@ -214,14 +217,14 @@ mod tests { let client = MockServerClient::new(); let mock = client.server.mock(|when, then| { when.method(httpmock::Method::GET) - .path("/zones/{zone_id}/recordsets".to_string()); + .path(format!("/zones/{zone_id}/recordsets", zone_id = "zone_id",)); then.status(200) .header("content-type", "application/json") .json_body(json!({ "recordsets": {} })); }); - let endpoint = Request::builder().build().unwrap(); + let endpoint = Request::builder().zone_id("zone_id").build().unwrap(); let _: serde_json::Value = endpoint.query(&client).unwrap(); mock.assert(); } @@ -232,7 +235,7 @@ mod tests { let client = MockServerClient::new(); let mock = client.server.mock(|when, then| { when.method(httpmock::Method::GET) - .path("/zones/{zone_id}/recordsets".to_string()) + .path(format!("/zones/{zone_id}/recordsets", zone_id = "zone_id",)) .header("foo", "bar") .header("not_foo", "not_bar"); then.status(200) @@ -241,6 +244,7 @@ mod tests { }); let endpoint = Request::builder() + .zone_id("zone_id") .headers( [( Some(HeaderName::from_static("foo")), diff --git a/openstack_sdk/src/api/dns/v2/zone/set.rs b/openstack_sdk/src/api/dns/v2/zone/set.rs index e0e081231..a22b7b435 100644 --- a/openstack_sdk/src/api/dns/v2/zone/set.rs +++ b/openstack_sdk/src/api/dns/v2/zone/set.rs @@ -101,7 +101,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/share/create.rs b/openstack_sdk/src/api/dns/v2/zone/share/create.rs index 5fb7b2035..6845b3d30 100644 --- a/openstack_sdk/src/api/dns/v2/zone/share/create.rs +++ b/openstack_sdk/src/api/dns/v2/zone/share/create.rs @@ -103,7 +103,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/abandon.rs b/openstack_sdk/src/api/dns/v2/zone/task/abandon.rs index e001780ad..d3d174d99 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/abandon.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/abandon.rs @@ -108,7 +108,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/export/create.rs b/openstack_sdk/src/api/dns/v2/zone/task/export/create.rs index 5c2d58168..421cb29b3 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/export/create.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/export/create.rs @@ -105,7 +105,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/import/create.rs b/openstack_sdk/src/api/dns/v2/zone/task/import/create.rs index 46c047fdd..5e0c4a5c4 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/import/create.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/import/create.rs @@ -95,7 +95,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/pool_move.rs b/openstack_sdk/src/api/dns/v2/zone/task/pool_move.rs index 495f2f87e..e62e8dc3a 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/pool_move.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/pool_move.rs @@ -109,7 +109,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/create.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/create.rs index de86bc006..b54cc0ced 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/create.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/create.rs @@ -95,7 +95,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/create.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/create.rs index c4748abbd..22778b9bc 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/create.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/create.rs @@ -107,7 +107,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/set.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/set.rs index 4ef12907e..e335eaf61 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/set.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/set.rs @@ -104,7 +104,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body() diff --git a/openstack_sdk/src/api/dns/v2/zone/task/xfr.rs b/openstack_sdk/src/api/dns/v2/zone/task/xfr.rs index 74e3b8bdf..5e60dcd3c 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/xfr.rs +++ b/openstack_sdk/src/api/dns/v2/zone/task/xfr.rs @@ -106,7 +106,7 @@ impl<'a> RestEndpoint for Request<'a> { let mut params = JsonBodyParams::default(); for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); + params.push(key.clone(), val.clone()); } params.into_body()